L
L
Lucker_Kophe2021-05-23 12:37:46
Python
Lucker_Kophe, 2021-05-23 12:37:46

Python Requests. Is it possible to login to a site with an invisible captcha re_captcha?

I want to login to a site with an invisible re_captcha to parse user data. Login to the site occurs with the knowledge of the user. I'm new to parsing, and I don't know how to enter the site with such a captcha. Is it possible? Can this be bypassed by knowing certain cookies?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maksam07, 2021-05-23
@Lucker_Kophe

TOKEN, EMAIL, PASS - to their own values. Code is working, tested

#!!! pip3 install 2captcha-python

import requests
from bs4 import BeautifulSoup
from twocaptcha import TwoCaptcha


def get_content(html):
    soup = BeautifulSoup(html, 'html.parser')
    item = soup.find('input', attrs={'name': '_csrf_token'})
    csrf = item['value']
    return csrf


solver = TwoCaptcha('TOKEN')
g_recaptcha = ''
try:
    result = solver.recaptcha(
        sitekey='6LftX68ZAAAAAOvXzEPz4lx9jgzfHdU3uVj-ptKT',
        url='https://3ddd.ru/login',
        invisible=1)

except Exception as e:
    exit(e)
else:
    g_recaptcha = result['code']

header = {
    # 'user-agent': user
}

url = 'https://3ddd.ru/login'
url_form = 'https://3ddd.ru/login_check'

loging = requests.get(url, headers=header)
loging_cookies = loging.cookies
login_csrf = get_content(loging.text)

datas = {
    '_username': 'EMAIL',
    '_password': 'PASS',
    '_csrf_token': login_csrf,
    'g-recaptcha-response': g_recaptcha,
}

loging2 = requests.post(url_form, data=datas, headers=header, cookies=loging_cookies)
print(loging2.text)

V
Vlad, 2021-05-23
@thoozu

You can, when using services for solving captcha

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question