Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 31, 2009 11:43
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 mattn/88157 to your computer and use it in GitHub Desktop.
Save mattn/88157 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Config::Pit;
use WWW::Mechanize;
use Web::Scraper;
use YAML;
my $config = pit_get(
'github.com',
require => {
'username' => 'your username on github.com',
'password' => 'your password on github.com'
}
);
my $mech = WWW::Mechanize->new();
$mech->add_header( 'Accept-Encoding', 'identity' );
$mech->get('https://github.com/login');
$mech->submit_form(
form_number => 2,
fields => {
login => $config->{username},
password => $config->{password},
}
);
my $res = $mech->get('https://github.com/dashboard/yours');
my $repos = scraper {
process '//div[contains(concat(" ",@class," ")," watching ")]//li',
'repos[]' => scraper {
process '//b/a', title => 'TEXT', url => '@href';
};
result 'repos';
}->scrape($res);
my $collabo = scraper {
process 'id("private-clone-url")', 'info' => scraper {
process '//a', title => 'TEXT', url => '@href';
};
result 'info';
};
for my $repo ( @{$repos} ) {
my $url = $repo->{url}->as_string . "/master";
my $info = $collabo->scrape( $mech->get($url) );
warn $url if $info->{url};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment