Net::Google::SafeBrowsing3::Lookup - Perl extension for the Google Safe Browsing v3 Lookup API.
use Net::Google::SafeBrowsing3::Lookup; my $gsb = Net::Google::SafeBrowsing3::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::SafeBrowsing3::Lookup implements the Google Safe Browsing v3.1 Lookup API. See the API documentation at https://developers.google.com/safe-browsing/lookup_guide.
If you need to check more than 10,000 URLs a day, you need to use Net::Google::SafeBrowsing3.
The source code is available on github at https://github.com/juliensobrier/Net-Google-SafeBrowsing3.
IMPORTANT: Google Safe Browsing v3.1 requires a different key than v3.0.
Create a Net::Google::SafeBrowsing3::Lookup object
my $gsb = Net::Google::SafeBrowsing3::Lookup->new( key => "my key", debug => 0, );
Arguments
Required. Your Google Safe Browsing API 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 STDOUT. 0 (disabled by default).
Optional. Google Safe Browsing version. 3.1 by default
Optional. Delay, in seconds, between 2 requests to the Google server. See the lookup function for more details. 0 (no delay) by default
lookup
Lookup a list URLs against the Google Safe Browsing v3 lists.
my %match = $gsb->lookup(url => 'http://www.gumblar.cn');
Returns a hash url => Google match. The possible list of values for Google match are: "ok" (no match), "malware", "phishing", "malware,phishing" (match both lists) and "error".
url
Google match
Optional. Single URL to lookup.
Optional. List of URLs to lookup.
The Lookup API allows only 10,000 URL checks a day. if you need more, use the Net::Google::SafeBrowsing3 library.
Each requests must contain 500 URLs at most. The lookup() method will split the list of URLS in blocks of 500 URLs if needed.
Optional. If more than 500 URLs are checked, wait delay seconds between consecutive requests to avoid rate limiting by Google.
delay
See Net::Google::SafeBrowsing3 for the implementation of Google Safe Browsing v3 API.
Julien Sobrier, <jsobrier@zscaler.com> or <julien@sobrier.net>
Copyright (C) 2015 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.
To install Net::Google::SafeBrowsing3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Google::SafeBrowsing3
CPAN shell
perl -MCPAN -e shell install Net::Google::SafeBrowsing3
For more information on module installation, please visit the detailed CPAN module installation guide.