我有一个包含 2500 个网站的列表,需要抓取它们的缩略图。我该怎么做?
我可以尝试使用 Perl 或 Python 解析网站,Mechanize 会是一件好事。但我对 Perl 不是很熟悉。
请您参考如下方法:
这是 Perl 解决方案:
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');
my $png = $mech->content_as_png();
来自文档:
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.
