Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import requests
- import time
- # set these!
- USERNAME = "" # e621 username
- API_KEY = "" # e621 api key
- # you need to enable API access to get a key.
- # to enable API access, you must go to your e621 API page (Account > Manage API Access) and generate an API key.
- pages = 400
- # setting up variables for POST request
- url = "https://e621.net/tags.json"
- headers = {'user-agent': 'tagSpecies/' + USERNAME}
- auth = requests.auth.HTTPBasicAuth(USERNAME, API_KEY)
- for i in range(1, pages+1, 1):
- r = requests.get(url, params = {"search[category]": "5", "limit": "1000", "search[order]": "count", "page": i}, headers=headers, auth=auth)
- # stop searches if we get any code back other than 200 (OK)
- if (r.status_code != 200):
- print("ERR:", r.status_code)
- exit
- f = open("species.txt", 'a')
- for curTag in r.json():
- FileLine = curTag['name'] + "\n" + "species:" + curTag['name'] + "\n\n"
- f.write(FileLine)
- ConsoleLine = curTag['name'] + " -> " + "species:" + curTag['name']
- print(ConsoleLine)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement