Z
Z
zilevsky2022-02-23 13:55:50
Python
zilevsky, 2022-02-23 13:55:50

The lxml library creates its own request and does not store the session?

When requesting a site via Session(), I store cookies. Then, using lxml, I parse the received page text for the token specified in the request form.
So in this way I collect all the data for a subsequent request.
But as it turned out, when parsing the page through lxml, it gives me a new token.
It turns out that lxml creates its own request and it does not pay attention to the session declared above?

No matter how much I searched for information on sessions of the lxml library, I could not find anything.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2022-02-23
@dimonchik2013

I just wrote an answer:
https://qna.habr.com/q/1119656
there are no sessions, they don’t exist, this is an abstraction : at the physical level there are POST / GET requests and cookies
for their development came up with POSTMAN (well, other insomnia) , practice
yes, there are "sessions" in requests and bs, for convenience, syntactic sugar, magic - no need to rely on this

D
Dr. Bacon, 2022-02-23
@bacon

I mixed everything together, lxml does not create any http request at all, and does not store the session, lxml is just an html parser. Requests and session is to requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question