clojure - Use Enlive to match a specific TD tag in a group of TD tags -


i getting started using elive html screen scraping task. if wanted text second , fourth td nodes of following table, how specify selector? read through tutorial didn't find examples of how specify in xpath be:

html/body/table/tr/td[2] , /td[4] (assuming one-based index)

<html> <body> <table width="100%"  border="0" cellspacing="3" cellpadding="2">   <tr>     <td width="15%" class="labels">part no</td>     <td class="datafield">i2013-00007</td>     <td class="labels"><div align="right">parcel no</div></td>     <td colspan="3" class="datafield">07-220-12-03-01-2-00-000</td>   </tr> </table> </body> </html> 

i need capture text value 2 td nodes.

you can use nth-of-type this:

user> (require '[net.cgrand.enlive-html :as html]) nil user> (def test-html  "<html><body><table width='100%'  border='0' cellspacing='3' cellpadding='2'><tr><td width='15%' class='labels'>part no</td><td class='datafield'>i2013-00007</td><td class='labels'><div align='right'>parcel no</div></td><td colspan='3' class='datafield'>07-220-12-03-01-2-00-000</td></tr></table></body></html>") #'user/test-html user> (:content (first (html/select (html/html-resource (java.io.stringreader. test-html)) [[:td (html/nth-of-type 2)]]))) ("i2013-00007") 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -