Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikeikaas committed Oct 25, 2018
1 parent ea2a5fb commit 3fe82b1
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions scraper.py
Expand Up @@ -62,18 +62,20 @@ def get_cell_value(element, css):
#athlete_url = athlete.cssselect("a")[0].get("href")
#parsed = urlparse.urlparse(athlete_url)
#athlete_id = urlparse.parse_qs(parsed.query)['competitorid']
result = {
'event': raceinfo['codex'],
'rank': result_cell.cssselect("td")[0].text_content(),
'athlete': result_cell.cssselect("td")[1].text_content(),
#'competitor_id': athlete_id,
'yob': result_cell.cssselect("td")[2].text_content(),
'nation': result_cell.cssselect("td")[3].text_content(),
'time': result_cell.cssselect("td")[4].text_content(),
'behind': result_cell.cssselect("td")[5].text_content(),
'points': result_cell.cssselect("td")[6].text_content()
}
print result
if len(result_cell.cssselect("td")) > 1:
result = {
'event': raceinfo['codex'],
'rank': result_cell.cssselect("td")[0].text_content(),
'athlete': result_cell.cssselect("td")[1].text_content(),
#'competitor_id': athlete_id,
'yob': result_cell.cssselect("td")[2].text_content(),
'nation': result_cell.cssselect("td")[3].text_content(),
'time': result_cell.cssselect("td")[4].text_content(),
'behind': result_cell.cssselect("td")[5].text_content(),
'points': result_cell.cssselect("td")[6].text_content()
}
print result
scraperwiki.sqlite.save(unique_keys=['athlete'], data=result, table_name="result")
print link
print raceinfo['date']
scraperwiki.sqlite.save(unique_keys=['codex'], data=raceinfo, table_name="data")
Expand Down

0 comments on commit 3fe82b1

Please sign in to comment.