爬虫-某游戏官网登录post提交(xpath版)
爬虫-某游戏官网登录post提交
本站下所有关于爬虫相关的技术只限于学习交流,请勿商用!切勿给对方服务器造成压力!
from requests_html import HTMLSession
session =HTMLSession()
response = session.get('http://auth.changyou.com/new_login.jsp')
token=response.html.xpath('//*[@name="loginToken"]/@value')[0]
user = '1mrjdl60vhqd@changyou.com'
pwd = '3kq6ozi'
url1 = 'https://auth.changyou.com/login'
data = {
'loginToken': token,
's': '',
'theme': 'null',
'isMiddleLogin':'',
'inputCnTime':'',
'cn': user,
'password': pwd
}
def get_time():
session.post(url=url1, data=data)
res = session.get('http://member.changyou.com/')
url = res.html.xpath('//a/@href')[0]
res_1 = session.get(url)
time =res_1.html.xpath('//*[@class="info"]/p/span/text()')
if time==[]:
session.post(url=url1, data=data,cookies={})
get_time()
else:
return time
res =session.post(url=url1, data=data,cookies={})
if '忘记密码' in res.text:
print('账号密码错误')
else:
print(get_time())
![微信](https://www.cnblogs.com/images/cnblogs_com/bladecheng/1492360/o_weinxin.png)
![QQ](https://www.cnblogs.com/images/cnblogs_com/bladecheng/1492360/o_qrcode_1561712740560.jpg)
个性签名:独学而无友,则孤陋而寡闻!
如果觉得这篇文章对你有小小的帮助的话,记得点个“关注”哦,博主在此感谢!还可以扫码添加好友,交流编程上的问题哦!
万水千山总是情,点赞再走行不行!哈哈哈(っ•̀ω•́)っ✎⁾⁾!