URL 到 PDF 解决方案
URL to PDF Solution
如何将此 URL 转为 PDF?
我正在尝试使用以下代码,但不起作用
我尝试将 URL 转换为 PNG,或页面的屏幕截图,但没有用,只是生成一个空的 pdf/image
有什么解决办法吗?
url:
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
我发现的问题是网络有一个 iframe,所以它看起来是空白的...如果你为这个 url 更改
然后它将起作用...如果您了解 html / css ,检查 google chrome 控制台您会找到它,也许您应该考虑使用 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)
如何将此 URL 转为 PDF? 我正在尝试使用以下代码,但不起作用 我尝试将 URL 转换为 PNG,或页面的屏幕截图,但没有用,只是生成一个空的 pdf/image
有什么解决办法吗?
url: 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
我发现的问题是网络有一个 iframe,所以它看起来是空白的...如果你为这个 url 更改
然后它将起作用...如果您了解 html / css ,检查 google chrome 控制台您会找到它,也许您应该考虑使用 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)