mechanize print to pdf [duplicate]

眉间皱痕 提交于 2019-12-13 07:13:30

问题


Possible Duplicate:
How do I grab a thumbnail screenshot of many websites?

I wrote a script using perl mechanize to login and fetch a page. How can I "print" that page to "pdf" directly from my perl script? I'd like to save a snapshot of how it looks in the browser.

I can get the html using $mech->content();


回答1:


Check out wkhtmltopdf - there are variants for PDF and images (PNG etc). It's basically a command-line tool wrapping the webkit html engine. Works quite nicely, and it's cross-platform too. Whether you can get it past your login form will depend on how the target site works.




回答2:


There's a number of CPAN modules to convert HTML to PDF. Feed any of them the content from Mechanize.




回答3:


The $mech contain plain html so you can't just print it. Check this thread: How do I grab a thumbnail screenshot of many websites?



来源:https://stackoverflow.com/questions/9029365/mechanize-print-to-pdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!