Python How to get Scrapy Xpath data from Basic Table? -
<table> <br> <tr> <td width = 270><p align="left" style="margin-left: 0;"><b>info</b></p></td> <td><p> </p></td> </tr> <tr> <td width = 270><p align="left" style="margin-left: 10;">page count</p></td> <td><p> = 4 </p></td> </tr> ...
trying response.xpath = 4
value table above. when inspecting element in chrome , pulling xpath way sill end [] value. tried:
/html/body/table[1]/tr[2]/td[2] //table[2]/tr[2]/td[2]
both fails.
i'd td
count
text instead , following-sibling
:
//td[contains(p, "count")]/following-sibling::td/p/text()
demo:
$ scrapy shell index.html in [1]: response.xpath('//td[contains(p, "count")]/following-sibling::td/p/text()').extract() out[1]: [u' = 4 ']
and if want extract actual number, use .re()
:
in [2]: response.xpath('//td[contains(p, "count")]/following-sibling::td/p/text()').re(r'(\d+)') out[2]: [u'4']
@admin
ReplyDeleteThese are the values that we hold central to our practice. We create beautiful smiles as we focus on the overall health of your mouth. We encourage you to call or email us with any questions or concerns that you have so that we can better serve you.
Regards,
Dentist In unionville, CT
@admin
ReplyDeleteOur doctors or dentists are to facilitate their advance techniques and educational experience, which provide patients with the best alternatives for oral health. Our team and dentists maintain to prepare themselves to provide maximum satisfaction for patients.
Regards,
Dentist In New Britain, CT