Skip to content

Instantly share code, notes, and snippets.

@lopnor
Created May 15, 2012 07:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lopnor/2699697 to your computer and use it in GitHub Desktop.
Save lopnor/2699697 to your computer and use it in GitHub Desktop.
#!perl
use 5.14.2;
use WWW::Mechanize;
use Getopt::Long;
use Term::Prompt;
use URI;
my $username;
my $baseurl;
GetOptions(
'username=s' => \$username,
'baseurl=s' => \$baseurl,
);
$username or die;
$baseurl or die;
my $password = prompt('p', 'password :', '','');
print "\n";
my $mech = WWW::Mechanize->new;
$mech->get('https://github.com/login');
$mech->submit_form(
form_number => 1,
fields => {
login => $username,
password => $password,
}
);
$baseurl .= '/issues' unless $baseurl =~ m{/issues$};
my $i = 0;
while (1) {
$i++;
my $uri = URI->new("$baseurl/$i");
$mech->get($uri);
$mech->res->code == 404 and last;
my $filename = $uri->path;
$filename =~ s{/}{_}g;
open my $fh, '>:utf8', $filename.'.html';
print $fh $mech->content;
close $fh;
}
@daipresents
Copy link

Issueバックアップの参考になりました。ありがとうございます。
1点、

form_number => 2,

じゃないと動きませんでした。ヘッダに検索窓ができちゃった影響かなーと。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment