Answer the question
In order to leave comments, you need to log in
Python parsing, how to login?
Good afternoon.
There was a need for parsing, and just started learning Python. The parser itself wrote according to the template, everything works, but you need to log in to the site https://shop.bohnenkamp-russia.ru/ and collect data, ~ 98 pages of the table.
I tried requests but faced with the fact that the url to which I am accessing is constantly changing, and I get the error Url is not def...
Tell me how in my case you can log in. Thank you all in advance!
import requests
def autoriz():
session = requests.Session()
url = ' https://shop.bohnenkamp-russia.ru/customer/ '
data = {'username':'******', 'password ':'*******'}
print (requests.get(url)).
autoriz()
if __name__ == '__main__':
main()
Answer the question
In order to leave comments, you need to log in
You create an instance of session, and you make a request outside the session and do not use data.
The official documentation says:
s = requests.Session()
s.auth = ('user', 'pass')
# необходимые заголовки, желательно сменить хотя бы User-agent
# иначе цель будет видеть вас как python requests и в 99% случаев блокировать
s.headers.update({'x-test': 'true'})
# both 'x-test' and 'x-test2' are sent
s.get('https://httpbin.org/headers', headers={'x-test2': 'true'})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question