-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.py
More file actions
53 lines (42 loc) · 1.34 KB
/
getData.py
File metadata and controls
53 lines (42 loc) · 1.34 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#############################################
#############################################
# libraries
from selenium import webdriver # for webdriving
import re # for finding text in webpages
from BeautifulSoup import BeautifulSoup # for parsing HTML
import selenium.webdriver.support.ui as ui # for waiting
import contextlib
import mechanize
import csv
import functions
#############################################
#############################################
# get postcodes
unitPostcodes = []
with(open('/Users/simon.walne/work/sustainability/postcodes.csv','r')) as f:
for i, line in enumerate(f):
if i> 10:
break
lineStr = line.strip()
lineStr = lineStr.replace(r'\n', '')
lineStr = lineStr.replace(r'\r', '')
lineStrSplit = lineStr.split(',')
if lineStrSplit[1] is not '':
unitPostcodes.append(lineStrSplit)
else:
continue
unitPostcodes.pop(0)
stopTable = []
busTable = []
for unit in unitPostcodes:
source = getSource(unit[1])
stopTable.extend(getStopTable(source, unit[1]))
busTable.extend(getBusTable(source, unit[1]))
#print(stopTable)
#writeFile('stopTable')
writeFile('busTable')
#crimeTable = []
#for unit in unitPostcodes:
# source = getCrimeSource(unit[1])
# crimeTable.append(getCrimeTable(source, unit[1]))
#writeFile('crimeTable')