https://github.com/memememomo/p5-WebService-Pixiv
中では、Web::Scraperを使ってCSS3セレクタでデータを取ってきているので、一瞬で動かなくなる可能性があります。
と思ってたら、昨日当たりに一部リニューアルがあったみたいで、さっそく動かなくなって涙目になってました。
以下、使い方メモ。
次のようにログインします。
my $client = WebService::Pixiv->new( pixiv_id => 'your pixiv id', passoword => 'your password', ); # 自分のuser_idを取得 my $user_id = $client->user_id; # イラストをダウンロード my $http_response = $client->download($illust_id);
次のようにイラストの情報が取れます。
my $illust_info = $client->illust_info($illust_id); # タイトル $illust_info->title; # キャプション $illust_info->description; # タグ $illust_info->targs; # サムネイルのURL $illust_info->thumbnail; # イラストのURL $illust_info->illust; # ダウンロード $http_response = $illust_info->download;
漫画作品の場合、ページ指定します。
# $page番目のイラストをダウンロード $client->download($illust_id, $page); # $page番目のイラストURLを取得 $illust_info->illust($page); # $page番目のイラストをダウンロード $illust_info->download($page); # ページ数を取得 $illust_info->page_count();
次のようにタグ検索ができます。
# タグ検索 my @tags = qw(巴マミ); my $search_illust = $client->search_illust(@tags); # ヒット数 $search_illust->count; # ヒットした1番目のイラスト情報 my $illust_info = $search_illust->get(0); # 2つ以上のタグでも検索が出来る my @tags = qw(巴マミ charlotte); my $search_illust = $client->search_illust(@tags);
その他、指定したユーザーの情報が取得できます。
# 指定したユーザーが投稿したイラスト my $member_illust = $client->find_member_illust($user_id); my $illust_info = $member_illust->get(0); # 指定したユーザーがブックマークしたユーザー my $bookmark_user = $client->find_bookmark_user($user_id); my $user_id = $bookmark_user->get(0); # 指定したユーザーがブックマークしたイラスト my $bookmark_illust = $client->find_bookmark_illust($user_id); my $illust_info = $bookmark_illust->get(0); # 指定したユーザーのマイピク my $mypixiv = $client->find_mypixiv($user_id); my $user_id = $mypixiv->get(0); # 指定したユーザーをブックマークする(第二引数は、0で公開、1で非公開) $client->bookmark_user($user_id, 0);