Last active
September 16, 2022 12:35
-
-
Save fastfingertips/05dc6e159228a21c60163b1c13d9aa63 to your computer and use it in GitHub Desktop.
Anilist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# The query to get the most popular anime | |
query = """ | |
query ($page: Int) { | |
Page (page: $page, perPage: 50) { | |
media (sort: POPULARITY_DESC, type: ANIME, isAdult: true) { | |
id | |
title { | |
romaji | |
english | |
} | |
episodes | |
} | |
} | |
} | |
""" | |
variables = {'page': 10} # The variables for the query | |
url = 'https://graphql.anilist.co' # The url to make the request to | |
response = requests.post(url, json={'query': query, 'variables': variables}) # Make the HTTP Api request | |
json_data = json.loads(response.text) # Convert the response to JSON | |
anime = json_data['data']['Page']['media'] # Get the anime data from the json response | |
for a in anime: # Print the anime with 12 episodes or less | |
if a['episodes'] <= 12: | |
print(a['title']['romaji'], a['episodes']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment