import requests
import json
from time import sleep
yzm_url = 'https://www.gushiwen.cn/RandCode.ashx'
login_url = 'https://www.gushiwen.cn/user/login.aspx?from=http://www.gushiwen.cn/user/collect.aspx'
header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36'}
s = response = requests.session()
response = s.get(url=login_url,headers=header)
sleep(1)
result =s.get(url=yzm_url,headers=header)
sleep(2)
image_data = result.content
with open('2.jpg','wb')as f:
f.write(image_data)
yzm_orc =input('请输入验证码')
data = {'__VIEWSTATE': 'xOzzv80EOuxiIrsb1j5mUZKaEbeFeJl+Q9DbMq1TOz5galkaLvxvSLt4wSFPZ6Th2fZsYDWC6LjDuEgM5qhV+SxwUL0LlLRpWPzlevb+PsEYbghWg8sPc3qEEfewvWwTK+k8CYHqFE53IHklT1PQEhTcC0E=',
'__VIEWSTATEGENERATOR':' C93BE1AE',
'from': 'http://www.gushiwen.cn/user/collect.aspx',
'email': 'you-email',
'pwd': 'you密碼',
'code': yzm_orc,
'denglu': '登录'}
print(data)
r=response=s.post(url=login_url,headers=header,data=data)
print(r.text)
sleep(3)