How do I grab a thumbnail screenshot of many websites?

浪子不回头ぞ 提交于 2019-11-28 10:39:45

问题


I have a list of 2500 websites and need to grab a thumbnail screenshot of them. How do I do that?

I could try to parse the sites either with Perl or Python, Mechanize would be a good thing. But I am not so experienced with Perl.


回答1:


Here is Perl solution:

  use WWW::Mechanize::Firefox;
  my $mech = WWW::Mechanize::Firefox->new();
  $mech->get('http://google.com');

  my $png = $mech->content_as_png();

From the docs:

Returns the given tab or the current page rendered as PNG image.

All parameters are optional. $tab defaults to the current tab. If the coordinates are given, that rectangle will be cut out. The coordinates should be a hash with the four usual entries, left,top,width,height.

This is specific to WWW::Mechanize::Firefox.

Currently, the data transfer between Firefox and Perl is done Base64-encoded. It would be beneficial to find what's necessary to make JSON handle binary data more gracefully.



来源:https://stackoverflow.com/questions/8381239/how-do-i-grab-a-thumbnail-screenshot-of-many-websites

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