Answer the question
In order to leave comments, you need to log in
How to login on the site?
Good evening
I practiced with the entrance to the forums, then I came across a site with protection (token), I seem to bypass the protection, but the login is still not carried out:
import requests
from bs4 import BeautifulSoup
url = "http://example.com"
loginurl = "https://example.com/users/sign_in"
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0)Gecko/20100101 Firefox/51.0',
"Host":"example.com"}
s = requests.Session()
responsePageWithAuth = s.get(loginurl, headers = headers) #получаю страницу users/sign_in для извлечения токена
#сам процесс получения не покажу, стыдно просто :) (предвижу кучу людей с наставлениями по правильному коду)
data = {"authenticity_token" : token,
"email" : "name%40domen.ru",
"password":"12345",}
response = s.post(loginurl, data=data, headers=headers) #ответ с результатом авторизации
soup = BeautifulSoup(response.content, "html.parser") #читаемый вид
print(soup.contents)
Answer the question
In order to leave comments, you need to log in
cookies, maybe they are somehow connected with the login?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question