我正在使用 ghost.py 来获取 html 页面的输出并将其呈现为 png。
该页面位于 node.js/express 服务器上,需要身份验证(使用 jwt)
问题是我无法理解是否发送了标头。
这是一个测试它的片段:
from ghost import Ghost
ghost = Ghost()
url = "myprotectedpage"
token = "myverylongjwttoken"
headers = {'Authorization': 'Bearer '+token}
with ghost.start(wait_timeout=10) as session:
page, extra_resources = session.open(url,headers=headers)
session.capture_to('test.png')
当我运行此代码时,我打印登录页面而不是实际页面,原因可能是标题未发送到页面。
关于如何找出标头有什么问题或以任何其他方式访问受保护资源的任何想法?(例如使用 cookielib 在 ghost.py 会话中存储 cookie)