python - HTML Parsing: Get elements between two elements? -
i'm parsing lxml on python 2.7
i have html looks this:
<tr height="45" valign="bottom"> <td colspan="2" class="date">wednesday, aug 5 2015 </td> </tr> <tr> <td/> </tr> <tr> <td> </td> <td/> </tr> <tr> <td/> <td> - no calendar matters set<br/></td> </tr> <tr height="45" valign="bottom"> <td colspan="2" class="date">thursday, aug 6 2015 </td> </tr>
is there way me list of td
element objects in between 2 elements of class="date"
?
basically, need info associated with, aug 5, since other elements before next date aren't children i'm struggling figure out how them.
write want: elements td[@class="date"] ahead , before
//td[following::td[@class="date"] , preceding::td[@class="date"]]
but set not contain td tags @class="date"
to include them use xpath
//td[(following::td[@class="date"] , preceding::td[@class="date"]) or @class="date"]
Comments
Post a Comment