-
Notifications
You must be signed in to change notification settings - Fork 0
/
PixivCrawler.py
46 lines (35 loc) · 1.27 KB
/
PixivCrawler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# coding: utf-8
from pixivpy3 import *
import json
from time import sleep
import os
api = PixivAPI()
f = open('client.json', 'r')
client_info = json.load(f)
f.close()
api.login(client_info['pixiv_id'], client_info['password'])
json_result = api.search_works("デフォルメ", page=1, per_page=30, mode='text')
# print(json_result)
if not os.path.exists("./pixiv_images"):
os.mkdir("./pixiv_images")
saving_directory_path = "./pixiv_images/"
aapi = AppPixivAPI()
separator = '------------------------------------------------------------'
total_works = json_result.pagination.total
total_pages = json_result.pagination.pages
per_page_works = json_result.pagination.per_page
for page_no in range(1, total_pages):
try:
json_result = api.search_works("デフォルメ", page=page_no, mode='text')
print('page: %d' % page_no)
print(separator)
for work_no in range(0, per_page_works):
illust = json_result.response[work_no]
print('Procedure: %d/%d' % (work_no + 1 + (page_no - 1) * 30, total_works))
print('Title: %s' % illust.title)
print(separator)
aapi.download(illust.image_urls.large, saving_directory_path)
sleep(1)
except:
continue
print('\nThat\'s all.')