Compare commits

...

1 Commits

Author SHA1 Message Date
6a442bb5bf delete scrap 2021-09-24 10:55:06 -07:00

View File

@ -1,35 +0,0 @@
# simple downloader in python; i couldn't get cookie to work in order to get sorted by popularity so this is only useful for getting results sorted by newest/oldest and non-r18
import argparse
import requests
from urllib.parse import quote as encodeURI
#cookie = open("cookie.txt", 'r').read()
cookie = None
ap = argparse.ArgumentParser()
ap.add_argument("tags")
ap.add_argument("-p", "--pages", type=int, default=1, help="number of pages")
args = ap.parse_args()
for i in range(1, args.pages+1):
url = f"https://www.pixiv.net/ajax/search/artworks/{encodeURI(args.tags, safe='')}?order=popular_d&mode=safe&p={i}"
print("get", url)
data = requests.get(url, headers={cookie: cookie}).json()
if (data['error']):
print(data['message'])
exit(1)
for item in data['body']['illustManga']['data']:
url = f"https://www.pixiv.net/ajax/illust/{item['id']}/pages"
print("get", url)
data = requests.get(url, headers={cookie: cookie}).json()
if (data['error']):
print(data['message'])
else:
for image in data['body']:
url = image['urls']['original']
filename = url.split('/').pop()
print("get", url)
req = requests.get(url, headers={'referer':'https://www.pixiv.net'})
open("download/"+ filename, "wb").write(req.content)
print("saved", filename)