我这里有个问题要解决,我被它困扰了两天。 我想用Python访问网站并获取未读消息的数量,但显然有一些小问题。我只是看到“客人”页面,而不是正确的登录页面。你知道吗
请帮我找出我的问题所在,我的代码如下。你知道吗
import requests
import os
import re
#import time
header_info ={
'Host': 'weavi.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Referer': 'https://weavi.com/',
'Connection': 'keep-alive',}
myS = requests.session()
r= myS.get("https://weavi.com")
myCookies= r.cookies
XSRF= re.findall('name="csrf-param" />\n<meta content=".+?" name="csrf-token" />',r.text,re.S)
XSRF_str= XSRF[0][36:-22]
login_data = {'username':'sera***@gmail.com','password':'***1230','redirect':'https://weavi.com/','authenticity_token':XSRF_str}
myS.post("https://weavi.com",data=login_data,headers=header_info,cookies=myCookies)
r=myS.get("https://weavi.com/")
message = re.findall('unread_message',r.text,re.S)
print message
网站中的表格张贴到
/login
:所以试试看:
我没有一个有效的帐户进行测试,所以请让我知道如果有任何问题。你知道吗
相关问题 更多 >
编程相关推荐