import requests
from lxml import etree
import urllib.request
from test_验证码 import Chaojiying_Clienturl = 'https://so.gushiwen.cn/user/login.aspx?from=http%3a%2f%2fso.gushiwen.cn%2fuser%2fcollect.aspx'
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
}
response = requests.get(url=url, headers=header)html = response.text
tree = etree.HTML(html)
__VIEWSTATE = tree.xpath('//*[@id="__VIEWSTATE"]/@value')
__VIEWSTATEGENERATOR = tree.xpath('//*[@id="__VIEWSTATEGENERATOR"]/@value')
img_src = 'https://so.gushiwen.cn' + tree.xpath('//*[@id="imgCode"]/@src')[0]
# urllib.request.urlretrieve(img_src,'./验证码/y.jpg')session = requests.session()
response_code = session.get(img_src)
content_code = response_code.content
with open('./验证码/y.jpg', 'wb') as fp:fp.write(content_code)chaojiying = Chaojiying_Client('1143238608', '1q2w3e4r', '930525') # 用户中心>>软件ID 生成一个替换 96001
im = open(r'./验证码/y.jpg', 'rb').read()
code = chaojiying.PostPic(im, 1902)['pic_str']data = {'__VIEWSTATE': __VIEWSTATE[0],'__VIEWSTATEGENERATOR': __VIEWSTATEGENERATOR[0],'from': 'http://so.gushiwen.cn/user/collect.aspx','email': '1143238608@qq.com','pwd': 'mxy19981028','code': code,'denglu': '登录',
}
# 执行登录操作
response_text = session.post(url=url, headers=header, data=data)content = response_text.text# with open('gushiwen.html','w',encoding='utf-8') as fp :
# fp.write(content)
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!