我试图登录到一个网站使用'请求和张贴'之前,我刮一些数据。 登录似乎不起作用,因为在中,我在登录之前和之后获得的数据没有差别。但是,如果我使用浏览器手动登录,则登录前后的数据不同,例如,我可以在主页上看到我的个人资料。我还将登录设置为try-except格式,以查看它是否显示任何异常,但运气不佳。 我已经检查并确保我正在输入所有的'表格数据'登录要求在页面上。 如有任何建议,将不胜感激。在
我的代码如下:
import urllib
import requests
from bs4 import BeautifulSoup as soup
POST_LOGIN_URL = 'https://wex.nz/login'
REQUEST_URL = 'https://wex.nz'
payload = {'email':'testemail@gmail.com','password':'testpassword'}
with requests.Session() as session:
try:
post = session.post(POST_LOGIN_URL, data=payload, headers={"Referer":"https://wex.nz"})
except:
print('login failed')
r = session.get(REQUEST_URL)
page_html= r.content
page_soup= soup(page_html, "html.parser")
profile_container=page_soup.findAll("div",{"class":"profile"})
print(profile_container)
目前没有回答
相关问题 更多 >
编程相关推荐