summaryrefslogtreecommitdiff
path: root/dumps
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-10-31 23:19:53 +0100
committeremkael <emkael@tlen.pl>2014-10-31 23:19:53 +0100
commitc3048ce08397e24e90688f090f98e8f999acfa6a (patch)
tree934eac54ced3eeac415c757e1da7e98ba7868e50 /dumps
parent9eabd017b4e7306bf59a9ef5776ed1d5a297e469 (diff)
* helper script for fetching qualifying data
Diffstat (limited to 'dumps')
-rw-r--r--dumps/chicane-f1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/dumps/chicane-f1.py b/dumps/chicane-f1.py
new file mode 100644
index 0000000..2d9b4cd
--- /dev/null
+++ b/dumps/chicane-f1.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+import urllib
+import urllib2
+import urlparse
+
+from lxml import html
+
+for year in range(1954,2015):
+ url = 'http://chicanef1.com/calendar.pl?' + urllib.urlencode({'year':year,'nc':0})
+ contents = urllib2.urlopen(url).read()
+ tree = html.fromstring(contents)
+ links = tree.xpath('//table[@cellpadding=6]//tr/td[1]//a')
+ for link in links:
+ url = urlparse.urlparse(link.attrib['href'])
+ url = url._replace(path='race.pl')
+ query = dict(urlparse.parse_qsl(url.query))
+ for type in ['qual', 'preq']:
+ query['type'] = type
+ url = url._replace(query=urllib.urlencode(query))
+ print urlparse.urljoin('http://chicanef1.com', urlparse.urlunparse(url))