Untitled
plain_text
2 months ago
2.8 kB
1
Indexable
Never
import requests from urllib.parse import urlencode import json from time import gmtime, strftime def ff16_download_ranking(region): url = 'https://web.np.playstation.com/api/graphql/v1//op?operationName=categoryGridRetrieve&variables={"id":"28c9c2b2-cecc-415c-9a08-482a605cb104","pageArgs":{"size":500,"offset":0},"sortBy":{"name":"downloads30","isAscending":false},"filterBy":[],"facetOptions":["ageRating","conceptGenres","conceptReleaseDate","conceptVrCompatibility","webBasePrice","productGenres","productReleaseDate","productVrCompatibility","storeDisplayClassification","targetPlatforms"],"maxResults":null}&extensions={"persistedQuery":{"version":1,"sha256Hash":"4ce7d410a4db2c8b635a48c1dcec375906ff63b19dadd87e073f8fd0c0481d35"}}' headers = {'x-psn-store-locale-override': region} data = json.loads(requests.get(url, headers=headers).text) namelist = [x["name"] for x in data["data"]["categoryGridRetrieve"]["concepts"]] if "FINAL FANTASY XVI" in namelist: return namelist.index("FINAL FANTASY XVI") else: return "圈外( >500 )" def ff16_sell_ranking(region): url = 'https://web.np.playstation.com/api/graphql/v1//op?operationName=categoryGridRetrieve&variables={"id":"28c9c2b2-cecc-415c-9a08-482a605cb104","pageArgs":{"size":500,"offset":0},"sortBy":{"name":"sales30","isAscending":false},"filterBy":[],"facetOptions":["ageRating","conceptGenres","conceptReleaseDate","conceptVrCompatibility","webBasePrice","productGenres","productReleaseDate","productVrCompatibility","storeDisplayClassification","targetPlatforms"],"maxResults":null}&extensions={"persistedQuery":{"version":1,"sha256Hash":"4ce7d410a4db2c8b635a48c1dcec375906ff63b19dadd87e073f8fd0c0481d35"}}' headers = {'x-psn-store-locale-override': region} data = json.loads(requests.get(url, headers=headers).text) namelist = [x["name"] for x in data["data"]["categoryGridRetrieve"]["concepts"]] if "FINAL FANTASY XVI" in namelist: return namelist.index("FINAL FANTASY XVI") else: return "圈外( >500 )" print(strftime("%Y-%m-%d %H:%M:%S UTC", gmtime())) print("FF16 按销售排名") print("日本:", ff16_sell_ranking("ja-JP")) print("美国:", ff16_sell_ranking("en-US")) print("德国:", ff16_sell_ranking("de-DE")) print("英国:", ff16_sell_ranking("en-GB")) print("加拿大:", ff16_sell_ranking("en-CA")) print("法国:", ff16_sell_ranking("fr-FR")) print("新西兰:", ff16_sell_ranking("en-NZ")) print("FF16 按下载排名") print("日本:", ff16_download_ranking("ja-JP")) print("美国:", ff16_download_ranking("en-US")) print("德国:", ff16_download_ranking("de-DE")) print("英国:", ff16_download_ranking("en-GB")) print("加拿大:", ff16_download_ranking("en-CA")) print("法国:", ff16_download_ranking("fr-FR")) print("新西兰:", ff16_download_ranking("en-NZ"))