简体   繁体   中英

XPath not working in Scrapy

I have the following XPath that I am trying to extract data from:

/html/body/div[2]/div[2]/div/div/div[4]/ul[2]/li/div

I am trying to simply test this through Scrapy Shell, so I do the following:

scrapy shell "https://www.rentler.com/listing/520583"

and then:

hxs.select('/html/body/div[2]/div[2]/div/div/div[4]/ul[2]/li/div').extract()

But this returns [] .

Any ideas?

Edit

The whole reason that I want to do this is because I need to breakup these 5 items into individual variables, not one array (which I currently have working):

<ul class="basic-stats">
<li>
<div class="count">4</div>
<div class="label">Bed</div>
</li>
<li>
<div class="count">2</div>
<div class="label">Bath</div>
</li>
<li>
<div class="count">1977</div>
<div class="label">Year</div>
</li>
<li>
<div class="count">1960</div>
<div class="label">SqFt</div>
</li>
<li>
<div class="count">0</div>
<div class="label">Acres</div>
</li>

I solved this. To access the individual items above, you simply add li[1],li[2], etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM