How Do I Download Files From The Web Using The Requests Module?
I'm trying to download a webpage data to samplefile.txt on my hard drive using the following code: import requests res = requests.get('http://www.gutenberg.org/cache/epub/1112/pg1
Solution 1:
import requests
res = requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt')
res.raise_for_status()
open('samplefile.txt', 'wb').write(res.content)
This is file samplefile.txt """The Project Gutenberg EBook of Romeo and Juliet, by William Shakespeare .... """
Post a Comment for "How Do I Download Files From The Web Using The Requests Module?"