Python requests-html: Render html with cookies

Question:

What I’m trying to do:

from requests_html import HTMLSession

with HTMLSession() as s:
    s.get('url', cookies=my_cookie_jar)
    s.html.render()
    print(s.html.html)

I want to access a page where I need to log-in. I already logged in using a selenium browser, where I then exported the cookies as a RequestsCookieJar.

Now when I print the text returned by the get-request, I receive the text of the correct webpage (but without the javescript rendered), but as soon as I render the html the cookies seem to have no effect and I get the html of a page asking me to log in (the same I get when issuing the request without the cookies in the first place).

Now my question:
Is it possible to specify the cookies when rendering the html (or should requests-html already do this by default)?

Answers:

Yes, you can, by using the kwarg cookies in render method.

s.html.render(cookies=my_cookie_jar)
Answered By: AlanWik

Solution, from Github (https://github.com/psf/requests-html/issues/109). Seems to work for me:

html.render(reload=False)
Answered By: Willem van Houten
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.