Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Created January 7, 2009 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyagawa/44200 to your computer and use it in GitHub Desktop.
Save miyagawa/44200 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/
use strict;
use warnings;
use Web::Scraper;
use URI::Escape;
use URI;
$| = 1;
my %authors;
while (<>) {
/^r\d+\s*\|\s*(\S+)/ or next;
unless (exists $authors{$1}) {
$authors{$1} = github_info($1);
}
}
sub github_info {
my $username = shift;
my $scraper = scraper {
process "#profile_name", name => 'TEXT';
process ".email", email => [ 'HTML', \&unmangle_js ];
};
my $res = eval { $scraper->scrape(URI->new("http://github.com/$username")) };
if ($res->{name} && $res->{email}) {
print "$username = $res->{name} <$res->{email}>\n";
}
return "blah";
}
sub unmangle_js {
/decodeURIComponent\(&#39;([%0-9a-f]+)/;
my $code = uri_unescape($1);
$code =~ /mailto:(.*?)"/ and return $1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment