Skip to content

Commit

Permalink
Add ability to map people
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonj04 committed Jul 12, 2018
1 parent 00a2b63 commit 49a87cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scraper.py
Expand Up @@ -17,6 +17,10 @@ def cleanup(string):
return string


PERSON_MAP = {
'229': 'Q55372604',
}

PARTY_MAP = {
'Conservative': 'Q9626',
'Garforth & Swillington Independents': 'Q55465979',
Expand Down Expand Up @@ -67,6 +71,7 @@ def cleanup(string):
parsedMembers = []
unreconciledWards = []
unreconciledParties = []
unreconciledPeople = []

print('(i) Scraping from ' + BASE_URL)

Expand Down Expand Up @@ -99,6 +104,11 @@ def cleanup(string):
idRegex = re.search('mgUserInfo\.aspx\?UID=([0-9]+)', linkHref)
memberData['id'] = idRegex.group(1)

if memberData['id'] in PERSON_MAP:
memberData['wikidata_id'] = PERSON_MAP[memberData['id']]
else:
unreconciledPeople.append(memberData['name'])

memberData['url'] = cleanup('https://democracy.leeds.gov.uk/mgUserInfo.aspx?UID=' + memberData['id'])

partyName = row.cssselect('td')[2].text
Expand All @@ -123,6 +133,8 @@ def cleanup(string):

print('(i) Done.')
print '(i) Counted {} Members in total'.format(len(parsedMembers))
print '<!> {} unreconciled people:'.format(len(unreconciledPeople))
print unreconciledPeople
print '<!> {} unreconciled wards:'.format(len(unreconciledWards))
print unreconciledWards
print '<!> {} unreconciled parties:'.format(len(unreconciledParties))
Expand Down

0 comments on commit 49a87cb

Please sign in to comment.