Perl extension for the google safe browsing v2 lookup api.
use Net::Google::SafeBrowsing2::Lookup; my $gsb = Net::Google::SafeBrowsing2::Lookup->new( key => "my key", ); my %match = $gsb->lookup(url => 'http://www.gumblar.cn/'); if ($match{'http://www.gumblar.cn/'} eq 'malware') { print "http://www.gumblar.cn/ is flagged as a dangerous site\n"; } my %matches = $gsb->lookup(urls => ['http://www.gumblar.cn/', 'http://flahupdate.co.cc']); foreach my $url (keys %matches) { print $url, " is ", $matches{$url}, "\n"; }
Net::Google::SafeBrowsing2::Lookup implements the Google Safe Browsing v2 Lookup \s-1API\s0. See the \s-1API\s0 documentation at <http://code.google.com/apis/safebrowsing/lookup_guide.html>.
If you need to check more than 10,000 URLs a day, you need to use Net::Google::SafeBrowsing2.
The source code is available on github at https://github.com/juliensobrier/Net-Google-SafeBrowsing2 <https://github.com/juliensobrier/Net-Google-SafeBrowsing2>.
Create a Net::Google::SafeBrowsing2::Lookup object
my $gsb = Net::Google::SafeBrowsing2::Lookup->new( key => "my key", debug => 0, );
Arguments
Required. Your Google Safe Browsing \s-1API\s0 key
Optional. Set to 1 to enable debugging. 0 (disabled) by default. The debug output maybe quite large and can slow down significantly the update and lookup functions.
Optional. Set to 1 to show errors to \s-1STDOUT\s0. 0 (disabled by default).
Optional. Google Safe Browsing version. 3.0 by default
Optional. Delay, in seconds, between 2 requests to the Google server. See the \*(C`lookup\*(C' function for more details. 0 (no delay) by default
Lookup a list URLs against the Google Safe Browsing v2 lists.
my %match = $gsb->lookup(url => 'http://www.gumblar.cn');
Returns a hash \*(C`url\*(C' => \*(C`Google match\*(C'. The possible list of values for \*(C`Google match\*(C' are: \*(L"ok\*(R" (no match), \*(L"malware\*(R", \*(L"phishing\*(R", \*(L"malware,phishing\*(R" (match both lists) and \*(L"error\*(R".
Arguments
Optional. Single \s-1URL\s0 to lookup.
Optional. List of URLs to lookup. The Lookup \s-1API\s0 allows only 10,000 \s-1URL\s0 checks a day. if you need more, use the Net::Google::SafeBrowsing2 library. Each requests must contain 500 URLs at most. The lookup() method will split the list of \s-1URLS\s0 in blocks of 500 URLs if needed.
Optional. If more than 500 URLs are checked, wait \*(C`delay\*(C' seconds between consecutive requests to avoid rate limiting by Google.
Documentation update.
See Net::Google::SafeBrowsing2 for the implementation of Google Safe Browsing v2 \s-1API\s0.
Julien Sobrier, <[email protected]> or <[email protected]>
Copyright (C) 2012 by Julien Sobrier
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.