【问题标题】:URL to PDF SolutionPDF 解决方案的 URL
【发布时间】:2020-02-23 07:02:45
【问题描述】:

如何将此 URL 传递给 PDF? 我尝试使用以下代码,但不起作用 我尝试使用 PNG 的 URL 或页面截图,但不起作用,只生成一个空的 pdf/图像

有什么办法吗?

网址: http://windte1910.acepta.com/v01/0EF57BFD40060E245941AE43E3F7DAB700A06338

代码:

import pdfkit

path_wkthmltopdf = r'C:\Program Files\wkhtmltopdf\bin\\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf = path_wkthmltopdf)

pdfkit.from_url("http://windte1910.acepta.com/v01/0EF57BFD40060E245941AE43E3F7DAB700A06338", "out2.pdf", configuration=config)

输出:

Loading pages (1/6)
Warning: A finished ResourceObject received a loading progress signal. This might be an indication of an iframe taking too long to load.
Warning: A finished ResourceObject received a loading finished signal. This might be an indication of an iframe taking too long to load.
Counting pages (2/6)
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      
True

【问题讨论】:

  • 你的 SO 是哪一个?
  • @GiovaniSalazar Windows 10
  • 我发现了一些......问题是网络有一个 iframe ..例如,如果你用这个 windte1910.acepta.com/ca4webv3/… 重新输入网址,这个工作......
  • @GiovaniSalazar 谢谢,这行得通!但在 url 中显示如下内容: %3A%2F%2F ,有没有办法用 :// 替换它?
  • 我在下面回答...您可以使用meyerweb.com/eric/tools/dencoder 对链接进行解码/编码

标签: python pdf url png screenshot


【解决方案1】:

我发现的问题是网络有一个 iframe,所以它显示为空白......如果你改变这个 url

http://windte1910.acepta.com/ca4webv3/index.jsp?url=http://windte1910.acepta.com/v01/0EF57BFD40060E245941AE43E3F7DAB700A06338

然后它会工作......如果你有 html / css 方面的知识,检查谷歌浏览器控制台你会找到它,也许你应该考虑使用 beautifulSoup 抓取来获取 iframe 的内容

import pdfkit

path_wkthmltopdf = r'C:\Program Files\wkhtmltopdf\bin\\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf = path_wkthmltopdf)

#pdfkit.from_url("http://windte1910.acepta.com/v01/0EF57BFD40060E245941AE43E3F7DAB700A06338", "out2.pdf", configuration=config)
pdfkit.from_url("http://windte1910.acepta.com/ca4webv3/index.jsp?url=http://windte1910.acepta.com/v01/0EF57BFD40060E245941AE43E3F7DAB700A06338", "out2.pdf", configuration=config)

【讨论】:

    猜你喜欢
    • 2011-06-30
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 1970-01-01
    • 2011-08-11
    • 2012-04-11
    相关资源
    最近更新 更多