Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Forked from anonymous/craiglist-apa.py
Created April 24, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanbehan/746e9204d9177512cdfabaecb0724637 to your computer and use it in GitHub Desktop.
Save seanbehan/746e9204d9177512cdfabaecb0724637 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