Created
January 23, 2022 14:58
-
-
Save shredEngineer/ec89e00740d00b0a3a09b5e831880f67 to your computer and use it in GitHub Desktop.
MetalArchives API in Python (Basic Example)
This file contains 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 json | |
import requests | |
def get_genre_prog(page): | |
# Website: https://www.metal-archives.com/lists/prog | |
# Request: https://www.metal-archives.com/browse/ajax-genre/g/prog/json/1?sEcho=9&iColumns=4 | |
# &sColumns=&iDisplayStart=0&iDisplayLength=500&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3 | |
# &iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true | |
# &bSortable_3=false&_=1642947935961 | |
# Request URL: | |
url = "https://www.metal-archives.com/browse/ajax-genre/g/prog/json/1" | |
# Request parameters: | |
params = { | |
"sEcho": 9, | |
"iColumns": 4, | |
"sColumns": "", | |
"iDisplayStart": page * 500, | |
"iDisplayLength": 500, | |
"mDataProp_0": 0, | |
"mDataProp_1": 1, | |
"mDataProp_2": 2, | |
"mDataProp_3": 3, | |
"iSortCol_0": 0, | |
"sSortDir_0": "asc", | |
"iSortingCols": 1, | |
"bSortable_0": "true", | |
"bSortable_1": "true", | |
"bSortable_2": "true", | |
"bSortable_3": "false", | |
"_": 1642947935961 | |
} | |
session = requests.Session() | |
session.headers.update({"User-Agent": "Custom user agent"}) | |
return session.get(url, params=params).json() | |
data = get_genre_prog(page=0) | |
# print(json.dumps(data, indent=4)) | |
print(json.dumps(data["aaData"], indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment