我需要将登录的网页转换为PDF。如何将通过硒get_cookies()获得的cookie传递给pdfkit?

问题描述 投票:0回答:1

代码显示如下:

    option = {'cookie': [(d['name'], d['value']) for d in driver.get_cookies()]}
    pdfkit.from_url(driver.current_url, 'test.pdf',options=option)
The output PDF file is blank.
python pdfkit
1个回答
0
投票

嗯,in pdfkit official document,它需要一个完整的元组列表。

在您的代码中,您使用的是pdfkit,它不是列表。您可以使用

dict5.items()

但是您的代码可以简化为:

ops = {'cookie':list(cookie_list)}
© www.soinside.com 2019 - 2024. All rights reserved.