Created
October 31, 2010 22:03
-
-
Save javisantana/657222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding: utf-8 | |
import urllib | |
import urllib2 | |
reg_nos = [16738, 17288, 18162, 18776, 18868, 19116, 19223, 19505]; | |
pdf_url = 'http://www.mapa.es/agricultura/pags/fitos/registro/sustancias/pdf/%s.pdf' | |
def fetch_url(url): | |
return urllib2.urlopen(url).read() | |
def save_url_as_file(url, filename): | |
open(filename,'wb').write(fetch_url(url)) | |
def download_pdf(reg_no): | |
f = '%d.pdf' % reg_no | |
save_url_as_file(pdf_url % reg_no, f) | |
print "\t- %s downloaded" % f | |
# tests | |
def single(regs): | |
for u in regs: | |
download_pdf(u) | |
single(reg_nos) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment