【发布时间】:2020-03-15 04:34:47
【问题描述】:
所以我正在尝试抓取我当前的电子邮件,可以通过 (https://ically.net/mail.php) 访问,同时尝试抓取此网站,
headers = {'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36"}
email = "icall3.amfoamfom@mf.net" #just some random email
def readEmail(email):
s = requests.Session()
logger.info(f"Using: {email}")
encodedBytes = base64.b64encode((str(email)).encode("utf-8"))
base = str(encodedBytes, "utf-8")
url = f"https://ically.net/#/{base}"
resp = s.get("https://ically.net/user.php",data={"user":email},headers=headers)
resp.raise_for_status()
resp = s.get("https://ically.net/mail.php?unseen=1",data={"unseen":1},headers=headers)
resp.raise_for_status()
resp = s.get("https://ically.net/mail.php")
resp.raise_for_status()
print(resp.text)
我最终保留了相同的 cookie,因为我没有更改我的电子邮件地址,它应该会显示我最新的电子邮件,但是当我提出这个请求时,我的输出是 DIE。这感觉有点苛刻。无论如何,我想就抓取/查看是否可以改进我正在尝试做的事情寻求帮助。 (我宁愿继续使用 requests 库,而不是使用 bs4 来做我正在做的事情)。
响应标头:
"{'Server': 'nginx', 'Date': 'Sun, 15 Mar 2020 04:44:32 GMT', 'Content-Type': 'text/html; charset=UTF-8', 'Content-Length': '23', 'Connection': 'keep-alive', 'X-Powered-By': 'PHP/7.0.33, PleskLin', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Pragma': 'no-cache', 'Set-Cookie': 'PHPSESSID=f5m6q05nutvkoon1rn432l8ke1; path=/', 'Vary': 'Accept-Encoding', 'Content-Encoding': 'gzip'}
[Finished in 2.4s]"
【问题讨论】:
-
让我换个说法:不要在评论部分添加数据!
-
请不要通过破坏您的帖子为他人增加工作量。通过在 Stack Exchange 网络上发帖,您已在 CC BY-SA 4.0 license 下授予 Stack Exchange 分发该内容的不可撤销的权利(即无论您未来的选择如何)。根据 Stack Exchange 政策,帖子的非破坏版本是分发的版本。因此,任何破坏行为都将被撤销。如果您想了解更多关于删除帖子的信息,请参阅:How does deleting work?
标签: python web-scraping python-requests