Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e2a5b61cf0379b419f79a54c81e07a1f to your computer and use it in GitHub Desktop.
Save anonymous/e2a5b61cf0379b419f79a54c81e07a1f to your computer and use it in GitHub Desktop.
parse craigslist apartments in vermont
from lxml.html import fromstring as html, tostring as tos
from requests import get
import xmltodict
import json
results = []
URL = 'http://vermont.craigslist.org/search/apa'
for el in html(get(URL).text).xpath("//p[@class='row']"):
results.append(xmltodict.parse(tos(el)))
print json.dumps(results, indent=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment