http://paperlined.org/src/pl/porn/google/kink.com_shootIds/fetch.pl

#!/usr/bin/perl

use lib '/home/interiot/cpan/lib/';
use Data::Dumper;
#use SOAP::Lite +trace; BEGIN { open(STDERR, '>>soap.trace'); }
#use SOAP::Lite +trace => [qw(transport)];
use SOAP::Lite;
#use SOAP::Data;

my @sites = (
    "hogtied.com",              # 0
    "fuckingmachines.com",      # 1
    "whippedass.com",           # 2
    "wiredpussy.com",           # 3
    "meninpain.com",            # 4
    "waterbondage.com",         # 5
    "ultimatesurrender.com",    # 6
    "sexandsubmission.com",     # 7
    "devicebondage.com",        # 8
    "tsseduction.com",          # 9
    "thetrainingofo.com",       # 10
    "behindkink.com",           # 11
);


my $site_name = shift or die "Please specify a domain name (e.g. 'hogtied.com' or 'wiredpussy').\n";

if ($site_name =~ /^\d\d?$/) {
    $site_name = $sites[$site_name];
}

print "Fetching shootIds for site:$site_name\n";

my $google_key = do{local*FIN; open FIN, "<$ENV{HOME}/.google.key" or die $!;<FIN>};
chomp $google_key;


my $service = SOAP::Lite->service('http://api.google.com/GoogleSearch.wsdl');


my @results = lots_of_results(
                $google_key,
                "site:$site_name/site/shoot.jsp",                  # query
                0,                                  # first
                10,                                 # count
                0,                                  # filter (hide similar results)
                "",                                 # restrict to a specific country or the like http://code.google.com/apis/soapsearch/reference.html#2_4
                0,                                  # enable SafeSearch filtering
                "",                                 # language restrict
                "",                                 # input encoding
                "",                                 # output encoding
                1000);                                # max # results

#print Dumper \@results, scalar(@results), "\n";

my @urls = map {$_->{URL}} @results;
#print join("\n", sort @urls), "\n"; exit;


my %shootIds;
foreach my $url (@urls) {
    if ($url =~ /shootId=(\d+)/i) {
        $shootIds{$1}++;
    }
}

open FOUT, ">>all.txt" or die "$!";
foreach my $shootId (sort {$a <=> $b} keys %shootIds) {
    print "$shootId $site_name\n";
    print FOUT "$shootId $site_name\n";
}
close FOUT;


#my %galleries = map {m#/g/\d+/(\d+)/i/#; $1=>1} @urls;     # (images) site:sexandsubmission.com, or site:promo.wiredpussy.com
#my %galleries = map {m#/[mg]/\d+/(\d+)/v/#; $1=>1} @urls;     # (video) site:sexandsubmission.com, or site:promo.wiredpussy.com
#my %galleries = map {m#galleries/ssm/([^/]*)/#; $1=>1} @urls;       # site:fragilehostage.com inurl:ssm
#my %galleries = map {m#free/ps/([^/]*)/#; $1=>1} @urls;       # site:damseldiary.com perfect-slave
#my %galleries = map {m#/(\d\d\d)/#; $1=>1} @urls;       # site:sinisterpain.com inurl:bedu
#my %galleries = map {m#http://(\d+)#; $1=>1} @urls;
#print join("\n", sort keys %galleries);

#print "-"x80, "\n";
#my %galleries = map {m#/images/([^/]*)/\d+#; $1=>1} @urls;       # site:damseldiary.com perfect-slave
#print join("\n", sort keys %galleries);

sub lots_of_results {
    my $max_count = pop(@_);
    my @args = @_;

    my $max_count_per_query = 10;

    my @all_results;

    for (my $start=0; $start<$max_count; $start+=$max_count_per_query) {
        $args[2] = $start;
        my $results = $service->doGoogleSearch(@args);

        push(@all_results, @{$results->{resultElements}});

        # stop if we don't receive the max results (probably indicating we've hit the end)
        last if (scalar(@{$results->{resultElements}}) < $max_count_per_query);
    }

    return @all_results;
}


Generated by GNU enscript 1.6.4.