Skip to content

Instantly share code, notes, and snippets.

@radoslawroszkowiak
Created January 7, 2016 17:53
Show Gist options
  • Save radoslawroszkowiak/8ecf53c618488a7bf3e9 to your computer and use it in GitHub Desktop.
Save radoslawroszkowiak/8ecf53c618488a7bf3e9 to your computer and use it in GitHub Desktop.
>>> import lxml.html
>>> tree = lxml.html.fromstring("""<html>
... <body>
... <div id=yw1>
... <table id="x">
... <thead></thead>
... <tbody>
... <tr>
... <td>
... <table id="y">
... <thead></thead>
... <tbody>
... <tr>
... <td><img src=".." title="Sample"></td>
... <td></td>
... </tr>
... </tbody>
... </table>
... </td>
... <td></td>
... </tr>
... </tbody>
... </table>
... </div>
... </body>
... </html>""")
>>> transfers = tree.xpath('//*[@id="yw1"]/table/tbody/tr')
>>> for transfer in transfers:
... print transfer.xpath('td[1]/table/tbody/tr[1]/td[1]/img/@title')
...
['Sample']
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment