I have a URL link that if I click on it, it will start downloading a file. The URL looks something like this:
http://somewebsite.com/download?f=someStrings
If I copy the URL and past it, in the URL bar of a web-browser it will start downloading as well.
How can I download the file using Python and preferably without using selenium.
You can download the file using the requests
module:
import requests as rq
r = rq.get('http://somewebsite.com/download?f=someStrings', allow_redirects=True)
open('filename.extension', 'wb').write(r.content)
Some points to note:
Replace http://somewebsite.com/download?f=someStrings
with your desired URL
Replace filename.extension
with file name and its file extension.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.