|
发表于 2020-7-31 10:58:07
|
显示全部楼层
- import requests
- from lxml import etree
- url = "https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.aspx"
- UA = {
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'}
- s = requests.session()
- r1 = s.get(url=url, headers=UA).text
- x1 = etree.HTML(r1)
- v_code = x1.xpath('//form[@name="aspnetForm"]/div[1]/input/@value')[0]
- p1 = 'https://so.gushiwen.cn' + x1.xpath('//*[@id="imgCode"]/@src')[0]
- p2 = s.get(url=p1, headers=UA).content
- with open('验证码.jpg', 'wb') as fp:
- fp.write(p2)
- tt = input("请输入验证码:")
- login_url = 'https://so.gushiwen.cn/user/login.aspx?from=http%3a%2f%2fso.gushiwen.cn%2fuser%2fcollect.aspx'
- data = {
- '__VIEWSTATE': v_code,
- '__VIEWSTATEGENERATOR': 'C93BE1AE',
- 'from':'http://so.gushiwen.cn/user/collect.aspx',
- 'email': '15701168930',
- 'pwd': 'abcd1234',
- 'code': tt,
- 'denglu': '登录'
- }
- r1 = s.post(url=login_url, headers=UA,data=data).text
- url_1 = 'https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.aspx'
- r2 = s.get(url_1,headers = UA)
- print(r2.text)
复制代码 |
评分
-
查看全部评分
|