diff options
author | emkael <emkael@tlen.pl> | 2014-11-07 12:54:17 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2014-11-07 12:54:17 +0100 |
commit | 50eda8dcf4c764493efe3cae4cf81df916ea2e7d (patch) | |
tree | 9da05438d7e65fce0ab2f5449ab8872ecc8abc58 /dumps/chicane-f1-nc.py | |
parent | 1a710ecacd2bc5d07289e1a26a64c2da819a878f (diff) |
* non-championship races dump from chicanef1
Diffstat (limited to 'dumps/chicane-f1-nc.py')
-rw-r--r-- | dumps/chicane-f1-nc.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/dumps/chicane-f1-nc.py b/dumps/chicane-f1-nc.py new file mode 100644 index 0000000..7e1ce57 --- /dev/null +++ b/dumps/chicane-f1-nc.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':1}) + contents = urllib2.urlopen(url).read() + tree = html.fromstring(contents) + links = tree.xpath('//table[@cellpadding=6]//tr/td[2]/center[text()="Non-championship"]/../..//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 ['h1q', 'heat1', 'heat2', 'agg', 'final', 'qual', 'res']: + query['type'] = type + url = url._replace(query=urllib.urlencode(query)) + print urlparse.urljoin('http://chicanef1.com', urlparse.urlunparse(url)) |