SMPLGRP
SMPLGRP

Reputation: 261

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>

Upvotes: 0

Views: 688

Answers (1)

SMPLGRP
SMPLGRP

Reputation: 261

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

Upvotes: 1

Related Questions