scripts/utilities/rule34.xxx-parser.py

38 lines
1.0 KiB
Python
Raw Normal View History

2023-02-17 21:30:46 +03:00
import requests
import json
import os
2023-04-04 02:48:35 +03:00
tags = input("Enter tags: ")
destination = input("Enter the directory you want dowload to (the directory will be created if not exists): ")
2023-02-17 21:30:46 +03:00
done = False
def download_url(url):
if not os.path.exists(destination):
os.makedirs(destination)
filename = url.split('/')[-1].replace(" ", "_")
path = destination + "/" + filename
print("Downloading: " + url + " -> " + path)
2023-02-17 21:47:38 +03:00
if os.path.exists(path):
print("Skipping downloaded content...")
return # skip downloaded content
2023-02-17 21:30:46 +03:00
resp = requests.get(url)
open(path, "wb").write(resp.content);
2023-02-17 21:41:14 +03:00
page = 0
2023-02-17 21:30:46 +03:00
while (not done):
2023-02-17 21:51:16 +03:00
post_count = 0
2023-02-17 21:30:46 +03:00
response = requests.get("https://api.rule34.xxx/index.php?page=dapi&s=post&json=1&q=index&tags=" + tags + "&pid=" + str(page) + "");
content = json.loads(response.content)
for entry in content:
post_count = post_count + 1
download_url(entry["file_url"])
2023-02-17 21:34:14 +03:00
if post_count == 100:
2023-02-17 21:30:46 +03:00
page = page + 1
else:
done = True
2023-02-17 21:51:16 +03:00
print("Done.")