Вёрстка
- 2 ответа
- 0 вопросов
2
Вклад в тег
url_login = 'http://mysite.com/login'
url_main = 'http://mysite.com/'
client = requests.session()
html = client.get(url_login)
cookies = html.cookies.get_dict()
soup = BeautifulSoup(html.text, 'lxml')
login_csrf = soup.find('input', dict(name='_csrf'))['value']
payload = {
'LoginForm[username]': '******',
'LoginForm[password]': '******',
'LoginForm[rememberMe]': 1,
'_csrf': login_csrf
}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36',
'Referer': url_main,
'Connection': 'keep-alive',
}
r = requests.post(url_login, cookies=cookies, data=payload, headers=headers)
print(r.status_code)
print(r.url)