-
Notifications
You must be signed in to change notification settings - Fork 0
/
craigslist_scraper.py
29 lines (20 loc) · 1 KB
/
craigslist_scraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# H/T BMuller for the gist
# http://stackoverflow.com/questions/14634108/automate-python-script to automate and store in a daily csv
# To Do: Figure out how to pull just price AND figure out how to deal with the cragslist doesn't like me pinging them question
# http://www.quora.com/What-is-the-best-way-to-set-up-a-Craigslist-screen-scraping-application
from robostrippy.resource import attr, attrList, Resource
class Connection(Resource):
subject = attr("h2.postingtitle")
subject = attr("h2.{hasPrice}price")
datetime = attr("time", attribute = "datetime")
class ConnectionListItem(Resource):
url = attr("a", attribute = 'href')
@property
def details(self):
return Connection(self.absoluteURL(self.url))
class ConnectionsList(Resource):
connections = attrList("span.pl", ConnectionListItem)
clist = ConnectionsList('https://newyork.craigslist.org/bik/#list')
# List of cities for comps and NYC 5 boroughs for depth
for connection in clist.connections:
print connection.details