Skip to content

Instantly share code, notes, and snippets.

@ishiduca
Created June 9, 2011 10:15
Show Gist options
  • Save ishiduca/1016470 to your computer and use it in GitHub Desktop.
Save ishiduca/1016470 to your computer and use it in GitHub Desktop.
get 'pixiv' staccfeed
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Pixiv::Download;
use Config::Pit qw(pit_get);
use JSON qw(decode_json);
my $home = 'http://www.pixiv.net';
my $stacc = "${home}/stacc/";
my $json_url = "${home}/stacc/my/home/all/all/js?tt=%%STACC_TOKEN%%";
my $config = pit_get('www.pixiv.net', require => {
pixiv_id => '', pass => '',
});
my $client = WWW::Pixiv::Download->new(
pixiv_id => $config->{pixiv_id},
pass => $config->{pass},
# look => 1,
);
$client->login;
my $ua = $client->user_agent;
# go to "http://www.pixiv.net/stacc/';
my $res = $ua->get($stacc);
die '! '. $res->status_line unless $res->is_success;
# get STACC_token && set Referer
$client->{referer} = $stacc;
$json_url =~ s/ %%STACC_TOKEN%% /($res->decoded_content =~ m!id="STACC_token"\s+value="([^"]+?)"!)[0]/xe;
# get stacc json
$res = $ua->get( $json_url );
die '! '. $res->status_line unless $res->is_success;
my $parse_json = decode_json $res->{_content};
#for my $status ( keys %{$parse_json->{status}} ) {
# print Dumper $parse_json->{status}->{$status};
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment