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&nbsp;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'] 

Comments

  1. @admin

    These 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

    ReplyDelete
  2. @admin

    Our 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


    ReplyDelete

Post a Comment

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -