-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraper.py
35 lines (25 loc) · 994 Bytes
/
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
30
31
32
33
34
35
import re
import scraperwiki
import requests
from lxml.html.soupparser import fromstring
from time import sleep
month = "Oct 17"
laurlroot = "http://planning.lewisham.gov.uk"
def search(mth):
request_data = {"month": mth, "dateType": "DC_Validated" , "searchType": "Application" }
sleep(2)
result = requests.post('http://planning.lewisham.gov.uk/online-applications/monthlyListResults.do?action=firstPage', request_data)
if not result:
print "No result returned"
return
result_dom = fromstring(result.content)
applications = result_dom.xpath("//li[@class='searchresult']")
print len(applications)
for application in applications:
link = "".join(application.xpath('a/@href')).strip()
description = "".join(application.xpath('a/text()')).strip()
address = "".join(application.xpath('p[@class="address"]/text()')).strip()
meta = "".join(application.xpath('p[@class="metaInfo"]/text()')).strip()
print link, address
print "Starting run"
search(month)