Net::Google::SafeBrowsing2::Lookup(3pm)

Net::Google::SafeBrowsing2::Lookup3pm

Perl extension for the google safe browsing v2 lookup api.

Usage

  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";
  }

Overview

Net::Google::SafeBrowsing2::Lookup implements the Google Safe Browsing v2 Lookup API. See the API 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>.

Constructor

new()

Create a Net::Google::SafeBrowsing2::Lookup object

  my $gsb = Net::Google::SafeBrowsing2::Lookup->new(
        key     => "my key", 
        debug   => 0,
  );

Arguments

key

Required. Your Google Safe Browsing API key

debug

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.

errors

Optional. Set to 1 to show errors to STDOUT. 0 (disabled by default).

version

Optional. Google Safe Browsing version. 3.0 by default

delay

Optional. Delay, in seconds, between 2 requests to the Google server. See the "lookup" function for more details. 0 (no delay) by default

Public functions

lookup()

Lookup a list URLs against the Google Safe Browsing v2 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".

Arguments

url

Optional. Single URL to lookup.

urls

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::SafeBrowsing2 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.

delay

Optional. If more than 500 URLs are checked, wait "delay" seconds between consecutive requests to avoid rate limiting by Google.

Changelog

0.2

Documentation update.

Releases

Unchanged in 3 releases since Debian 8 (Jessie).

  1. 8–10

Author

Julien Sobrier, <[email protected]> or <[email protected]>

From libnet-google-safebrowsing2-perl 1.07-6 in Debian 10 (Buster). Parsed by carta from the page's man source.