Reputation: 11
I'm trying to login to a webpage through python requests. And I need a g-recaptcha-response in my payload to be able to login (i think so). Im using a service named AntiCaptchaOfficial to solve it, but when a send requests with payload its go to main page with error: "Captcha error occurred. Please reload the page."
My code:
import requests
from bs4 import BeautifulSoup
URL = 'https://qxbroker.com/en/sign-in/'
with requests.Session() as session:
user = fake_useragent.UserAgent().random
stat, solved = captcha()
if stat != True:
exit()
headers = {'user-agent': str(user)}
response = session.get(URL, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
token = soup.find('input', {'name': '_token'}).get('value')
cookies = response.cookies
data={'_token':str(token),
'email': 'myemail',
'password':'mypass',
'g-recaptcha-response': str(solved)}
y = session.post(URL,data=data, headers=headers, cookies=cookies)
print(y.text)
Im check all POST and GET and i think its OK! Thanks for helping me!
Upvotes: 0
Views: 3040
Reputation: 201
The most likely explanation is that the Captcha service detected your attempt at circumventing it, and blocked your automated request as per the wishes of the webmaster.
It is hard to say how this detection happened because it is probably some trade secret. Even if I told you here, bot masters would start using it and ReCaptcha would quickly change it, rendering this answer incorrect for future readers.
You probably need additional headers, cookies, referrers or any number of other things in your request. It is unlikely that anyone on StackOverflow will reverse engineer the site for you. Your best option is probably to look for another site, or pay for their API (if there is one).
Upvotes: 1