import requests
import fake_useragent
from bs4 import BeautifulSoup
user = fake_useragent.UserAgent().random
datas = {
'_username':'def',
'_password':'def',
'_csrf_token':'def'
}
header = {
'user-agent': user
}
url = 'https://3ddd.ru/login'
url_form = 'https://3ddd.ru/login_check'
s = requests.Session()
loging = requests.get(url, headers=header)
def get_content(html):
soup = BeautifulSoup(html, 'html.parser')
item = soup.find('input', attrs={'name': '_csrf_token'})
csrf = item['value']
return csrf
datas['_username'] = '*****'
datas['_password'] = '******'
datas['_csrf_token'] = get_content(loging.text)
loging2 = s.post(url_form, data = datas, headers=header)
datas = {
'_username':'def',
'_password':'def'
}
header = {
'user-agent': user
}
<div id="content"><div id="avtorisation_page"><h2 class="avtorisation">�����������</h2><form action="/login_check" method="post" id="autorisation_form_1"><input type="hidden" name="_csrf_token" value="AwlIWckTA3OCk-qCEEtTg-IwUtGsiDZF0HqqrIPlXJQ" /><dl><dt> </dt><dd class="form_error">
������ CSRF
</dd><dt> </dt><dd class="form_error1">
� ����� ������������ �� ��������� ����������� ����� �� �������. ����������� email ��� �����.
</dd><dt><label for="aut_login">Email</label></dt><dd><input type="email" class="text_button" id="username" name="_username" value="" required="required" pattern="([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$"></dd><dt><label for="aut_password">������</label></dt><dd><input type="password" class="text_button" id="password" name="_password" required="required" autocomplete="off"></dd></dl><input type="hidden" id="sky_user_login__remember_me" name="sky_user_login[_remember_me]" value="on" /><div class="butons"><button type="submit" class="sub_button_green unactive button_grey g-recaptcha" disabled id="login_form_submit"
data-sitekey="6LftX68ZAAAAAOvXzEPz4lx9jgzfHdU3uVj-ptKT"
data-callback='onSubmit'
data-action='submit'>�����</button><span class="forget_password"><a href="/resetting/request">������ ������?</a></span></div><div class="register">��� �� ������������������? <a href="/register/register">������������������ ������</a></div></form></div></div>
<div id="sidebar" >
</div>
<div class="pfooter"></div>
$captcha;
if (isset($_POST['token'])) {
$captcha = $_POST['token'];
}
$secretKey = 'SecretKey';
$ip = $_SERVER['REMOVE_ADDR'];
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secretKey . '&response=' . $captcha;
$response = file_get_contents($url);
$responseKeys = json_decode($response, true);
header('Content-type: application/json');
if($responseKeys["success"] && $responseKeys["score"] >= 0.5) {
echo json_encode(array('success' => 'true', 'om_score' => $responseKeys["score"], 'token' => $_POST['token']));
} else {
echo json_encode(array('success' => 'false', 'om_score' => $responseKeys["score"], 'token' => $_POST['token']));
}
grecaptcha.ready(function() {
grecaptcha.execute('SiteKey', {action: 'homepage'}).then(function(token) {
tk = token;
document.getElementById('token').value = token;
const data = new URLSearchParams();
for (const pair of new FormData(document.querySelector('form'))) {
data.append(pair[0], pair[1]);
}
fetch('recaptcha.php', {
method: 'post',
body: data,
})
.then(response => {
console.log(response.text());
return response.json()
})
.then(result => {
if (result['om_score'] >= 0.5 && error_time == 0) {
submit.className += ' okay-form'; submit.disabled='disabled'; submit.innerHTML='Отправлено';
$name.className += ' okay-form';
$email.className += ' okay-form';
$phone.className += ' okay-form';
$message.className += ' okay-form';
setTimeout(function () {
form.submit()
}, 4000);
} else {
console.log('Бот')
}
});
});
});
let Re_form = document.querySelector('form');
Re_form.onmouseover = function () {
let Tempscript = document.createElement('script');
Tempscript.src = "https://www.google.com/recaptcha/api.js?render=SiteKey";
document.querySelector('.recaptcha_JS').insertAdjacentElement('afterend', Tempscript);
}