I get every day one specific email with a link in it. Then I klick the link which opens a browser, and then I save the webpage as a html file. That is what I have to do every day. Until now I do it manually, but I guess that it is a way to do it with python. I only know for now how to save an attachment from an email using python. But I don't know what to do with a link. Have somebody some experience with it?
Thanks in advance
You can do this with the requests
package. Assuming you've already extracted the link as a string
link = 'https://...'
from requests import get
resp = get(link)
with open('todays-file.html', 'wb') as fOut:
fOut.write(resp.content)
You will probably want to add handling if the link is bad (ie does not return a 20x status code), but that's the general idea.
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.