From d2b7c15ff3c5a5c77ede7ac2b9f78462542fe83a Mon Sep 17 00:00:00 2001 From: leca Date: Fri, 17 Feb 2023 21:30:46 +0300 Subject: [PATCH] added rule34.xxx-parser.py --- utilities/rule34.xxx-parser.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 utilities/rule34.xxx-parser.py diff --git a/utilities/rule34.xxx-parser.py b/utilities/rule34.xxx-parser.py new file mode 100644 index 0000000..1fb0e47 --- /dev/null +++ b/utilities/rule34.xxx-parser.py @@ -0,0 +1,32 @@ +import requests +import json +import os + +tags = str(input("Enter tags: ")) +destination = str(input("Enter the directory you want dowload to (the directory will be created if not exists): ")) +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) + resp = requests.get(url) + open(path, "wb").write(resp.content); + + +while (not done): + post_count = 0 + page = 0 + 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"]) + + if post_count < 100: + page = page + 1 + post_count = 0 + else: + done = True