That's strange. When I try in scrapy shell I do get those text elements in 
the same order.

paul@paul:~/dev/js2xml$ scrapy shell
2014-05-19 16:06:22+0200 [scrapy] INFO: Scrapy 0.23.0 started (bot: 
scrapybot)
2014-05-19 16:06:22+0200 [scrapy] INFO: Optional features available: ssl, 
http11
2014-05-19 16:06:22+0200 [scrapy] INFO: Overridden settings: 
{'LOGSTATS_INTERVAL': 0}
2014-05-19 16:06:22+0200 [scrapy] INFO: Enabled extensions: TelnetConsole, 
CloseSpider, WebService, CoreStats, SpiderState
2014-05-19 16:06:22+0200 [scrapy] INFO: Enabled downloader middlewares: 
HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, 
RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, 
HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, 
ChunkedTransferMiddleware, DownloaderStats
2014-05-19 16:06:22+0200 [scrapy] INFO: Enabled spider middlewares: 
HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, 
UrlLengthMiddleware, DepthMiddleware
2014-05-19 16:06:22+0200 [scrapy] INFO: Enabled item pipelines: 
2014-05-19 16:06:22+0200 [scrapy] DEBUG: Telnet console listening on 
0.0.0.0:6023
2014-05-19 16:06:22+0200 [scrapy] DEBUG: Web service listening on 
0.0.0.0:6080
[s] Available Scrapy objects:
[s]   crawler    <scrapy.crawler.Crawler object at 0x7f24edf96610>
[s]   item       {}
[s]   settings   <CrawlerSettings module=None>
[s] Useful shortcuts:
[s]   shelp()           Shell help (print this help)
[s]   fetch(req_or_url) Fetch request (or URL) and update local objects
[s]   view(response)    View response in a browser
/usr/local/lib/python2.7/dist-packages/IPython/frontend.py:30: UserWarning: 
The top-level `frontend` package has been deprecated. All its subpackages 
have been moved to the top `IPython` level.
  warn("The top-level `frontend` package has been deprecated. "

In [1]: import scrapy.selector

In [2]: selector = 
scrapy.selector.Selector(text="""<ul><li>1</li><li>2</li><li>3</li></ul>""", 
type="html")

In [3]: selector.xpath('//ul/li/text()').extract()
Out[3]: [u'1', u'2', u'3']

In [4]: 




Could you share some of your code?

On Monday, May 19, 2014 4:00:10 PM UTC+2, jinchao wang wrote:
>
> May I ask a question:   how to get the elements in their origin order 
> withing selector.xpath()
> for example, <ul><li>1</li><li>2</li><li>3</li></ul>,   I want [1, 2, 3], 
> but it return [2,3,1]
> I use this xpath experssion: //ul/li/text()
> thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to