forked from SuperTony0/apartment-finder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finder.py
32 lines (27 loc) · 1.03 KB
/
finder.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
30
31
32
from craigslist import CraigslistHousing
from functions import in_box
from functions import posted_recently
import settings
import sender
from database import Database
database = Database()
print('Starting scrape...')
houses = CraigslistHousing(site=settings.CRAIGSLIST_SITE, category='apa',
filters={'max_price': settings.MAX_PRICE, 'min_price': settings.MIN_PRICE,
'bedrooms': [3,5]})
results = houses.get_results(sort_by='newest', geotagged=True, limit=1000)
apartments = []
for result in results:
geotag = result["geotag"]
# if geotag is not None and posted_recently(result):
if geotag is not None:
for box in settings.BOXES.items():
if in_box(geotag, box[1]):
if not database.contains(result['id']):
print('adding: ' + str(result['id']))
database.add(result)
sender.post_to_slack(result, box[0])
else:
print('already exists: ' + str(result['id']))
break
print('Scrape done')