Created
March 9, 2009 01:06
-
-
Save miyagawa/76030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Web::Scraper; | |
use Pod::Usage; | |
use URI::Escape; | |
use URI; | |
my $id = shift or pod2usage(0); | |
my @finders = (\&scrape_github, \&scrape_cpan); | |
for my $finder (@finders) { | |
my $res = eval { $finder->($id) }; | |
if ($res->{name}) { | |
print "$id = $res->{name} <$res->{email}>\n"; | |
} | |
} | |
sub scrape_github { | |
scraper { | |
process "#profile_name", name => 'TEXT'; | |
process ".email", email => [ 'HTML', \&decode_github_email ]; | |
}->scrape(URI->new("http://github.com/$_[0]")); | |
} | |
sub scrape_cpan { | |
scraper { | |
process ".t1", name => 'TEXT'; | |
process '//a[contains(@href, "mailto:")]', email => 'TEXT'; | |
}->scrape(URI->new("http://search.cpan.org/~$_[0]")); | |
} | |
sub decode_github_email { | |
if (/decodeURIComponent\('(.*?)'/) { | |
my $code = uri_unescape($1); | |
$code =~ /"mailto:(.*?)"/ and return $1; | |
} | |
return; | |
} | |
__END__ | |
=head1 NAME | |
whois-hacker - Search hacker's information from the Net | |
=head1 SYNOPSIS | |
whois-hacker nickname | |
=head1 DESCRIPTION | |
This is a small command-line script to get a hacker's information from | |
websites like Github and CPAN. Useful to get name and email when you | |
want to bug someone, or add to put in svn.authorsfile when you convert | |
SVN repository to git. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment