简体   繁体   English

python - 从url到PDF的pdfkit

[英]python - pdfkit from url to PDF

I'm trying to convert Web Page to PDF using the code below. 我正在尝试使用下面的代码将网页转换为PDF。

import pdfkit
pdfkit.from_url(str(url), 'out.pdf')

But I need first to register to the web. 但我需要先注册网络。

How can I Add username and password as parameters in the Url?? 如何在Url中添加用户名和密码作为参数?

Best option is transmitting a cookie of a connected user to pdfkit. 最佳选择是将连接用户的cookie传输到pdfkit。

  1. Login normally by sending credentials using urllib or anything that can do http request. 通过使用urllib或任何可以执行http请求的内容发送凭据来正常登录。
  2. Retrieve cookie sends by server from headers 检索服务器从标头发送的cookie
  3. pdfkit.from_url(str(url), 'out.pdf', options={ cookie: 'cookiename cookievalue' })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM