Skip to content

Instantly share code, notes, and snippets.

@javisantana
Created October 31, 2010 22:03
Show Gist options
  • Save javisantana/657222 to your computer and use it in GitHub Desktop.
Save javisantana/657222 to your computer and use it in GitHub Desktop.
#!/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