我正在尝试使用python请求登录。我提出GET请求并获取验证码。我解决了验证码,然后提出了带有必要有效负载的POST请求。但是验证码已更改(或没有更改?),所以我的回答不正确。我正在使用会话,但即使这样也不起作用。任何建议/帮助表示赞赏。
session = requests.session()
prox = {'http':'socks5h://localhost:9050',
'https': 'socks5h://localhost:9050'}
session.proxies = prox
em_url = 'http://b4lzbnzx55o7d6yutrhrbgku35fl3hy6r7eyx7veorw6qwih27covjid.onion/'
response = session.get(f'{em_url}')
doc = BeautifulSoup(response.text, 'lxml')
form = doc.find('form').find_all('div')
name = form[0].find('input')['name']
pswd = form[1].find('input')['name']
img = form[3].find('img')['src']
cap = form[4].find('input')['name']
print(img, '\n\n') # I get the url of the captcha
cap_ans = input() # Giving captcha's output manually for testing
payload = {
name:'myUsername',
pswd:'myPassword',
cap:cap_ans,
}
login_wrap = form[5].find_all('input')
hid_data = []
for x in login_wrap: # There are some hidden inputs too
payload[x['name']] = x['value']
resp = session.post(f'{em_url}', data=payload)
print('status', resp.status_code)
print(resp.text) # I should be logged in now, but that doesn't happen and i get an invalid captha error