Home > other >  Landing simulation for help
Landing simulation for help

Time:09-19

 import requests 
The from LXML import etree
The import base64
The from PIL import Image

The session=requests. The session ()
Url="https://so.gushiwen.org/user/login.aspx? from=http://so.gushiwen.org/user/collect.aspx '
Headers={
'the user-agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 '
}
Page_text=session. Get (url=url, headers=headers,). The text
The tree=etree. HTML (page_text)
Img_src='https://so.gushiwen.org' + tree. Xpath ('//* [@ id="imgCode"]/@ SRC ') [0]
Res=requests. Get (url=img_src). The content
With the open ('./code. GIF ', 'wb) as f:
F.w rite (res)
Image. The open (' code. GIF). The save (' code. PNG ')

"'
General character recognition
"'

The host='https://aip.baidubce.com/oauth/2.0/token? Grant_type=client_credentials & amp; Client_id=L9BNPAgFmP7RRB4D0cFlhGUi & amp; The client_secret=eqE1iCj0kcMk53lpjMv3KbBoItX5MrkG '
The response=requests. Get (the host). Json ()
Access_token=response [' access_token ']
Request_url="https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"
# binary way to open the image file
F=open (' code. PNG ', 'rb')
Img=base64. B64encode (f.r ead ())

Params={" image ": the img}
# access_token=host
Request_url=request_url + "? Access_token="+ access_token
The content-type headers={' ':' application/x - WWW - form - urlencoded '}
The response=requests. Post (request_url data=https://bbs.csdn.net/topics/params, headers=headers). The json ()
Code=response [' words_result] [0] [' words']
Print (code)

Login_url='https://so.gushiwen.org/user/login.aspx? From=http%3a%2f%2fso.gushiwen.org % 2 fuser % 2 fcollect. Aspx '
Data={
https://bbs.csdn.net/topics/'__VIEWSTATE' : 'Em4iCpnL3M3DrcgCu77COw33yUvSBkBcNV9Alv2 + 79 sgfsgvhqyvpsi7lnruv6yr3zl1zhvohez60jaqmrf2ssbvkpnxxmruezgx1xgyqf1if1pvwgucp8ivg + k='
'__VIEWSTATEGENERATOR' : 'C93BE1AE',
'from' : 'http://so.gushiwen.org/user/collect.aspx',
'email' : '@qq.com' 1303541051,
'the PWD' : 'zdy0519',
'code' : code,
'denglu' : 'log on'
}

Page_text=session. Post (url=Login_url, headers=headers, data=https://bbs.csdn.net/topics/data). The text
With the open (' gushiwen. HTML ', 'w', encoding="utf-8") as f:
F.w rite (page_text)



This is my simulation of land net of a classical code, but always prompt verification code error, I looked at the baidu cloud recognize captcha yes ah, excuse me, where is the problem

CodePudding user response:

Headers should be inside need to add the manual verification information through generated after the cookies

CodePudding user response:

I use the session is to get the cookies and I also tried in headers added cookie is not

CodePudding user response:

reference 1st floor wangcj201592042 response:
headers should be inside need to add the manual verification through cookies information generated after


Settled, images to obtain there should use the session, I am useless
  • Related