【发布时间】:2020-09-15 14:02:19
【问题描述】:
我想要做什么:
from requests_html import HTMLSession
with HTMLSession() as s:
s.get('url', cookies=my_cookie_jar)
s.html.render()
print(s.html.html)
我想访问需要登录的页面。我已经使用 selenium 浏览器登录,然后将 cookie 导出为 RequestsCookieJar。
现在,当我打印 get-request 返回的文本时,我收到了正确网页的文本(但没有呈现 javescript),但是一旦我呈现 html,cookie 似乎就没有效果,我得到了要求我登录的页面的 html(与最初在没有 cookie 的情况下发出请求时得到的相同)。
现在我的问题是:
是否可以在渲染 html 时指定 cookie(或者 requests-html 是否应该默认已经这样做了)?
【问题讨论】:
标签: python python-requests-html