Skip to content

Instantly share code, notes, and snippets.

@Gunio
Created October 18, 2011 18:33
Show Gist options
  • Save Gunio/1296255 to your computer and use it in GitHub Desktop.
Save Gunio/1296255 to your computer and use it in GitHub Desktop.
Parsing HTML in Python with LXML
import requests
import lxml
from lxml import html
r = requests.get('http://gun.io')
tree = lxml.html.fromstring(r.content)
elements = tree.get_element_by_id('frontsubtext')
for el in elements:
print el.text_content()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment