How to download pdf files in python? [closed]

You can use the pattern module, which is built on top of urllib2 and has a higher level of abstraction.

from pattern.web import URL

url = URL('http://query.nytimes.com/mem/archive-free/pdf?res=9A00EEDE1431E13BBC4850DFBF66838A649FDE')
f = open('nytimes.pdf', 'wb')
f.write(url.download(cached=False))
f.close()

Leave a Comment