Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- from bs4 import BeautifulSoup
- total = 0
- for i in range(1, 75):
- print("PAGE{}".format(i))
- print("Current TOTAL: {}".format(total))
- sup = BeautifulSoup(
- requests.get("https://store.playstation.com/en-us/grid/STORE-MSF77008-PS3ALLPS3GAMES/{}?gameType=ps3_full_games%2Cminis%2Cps2_classics%2Cpsone_classics%2Cpsn_games%2Cdisc_only&platform=ps3".format(i)).content,
- 'lxml')
- for x in sup.find_all('div', {'class': 'grid-cell__title '}):
- y = None
- while True:
- try:
- print('https://store.playstation.com/valkyrie-api/en/us/999/resolve/{}?depth=999'.format(
- x.parent['href'].split('/')[-1]))
- y = json.loads(requests.get(
- 'https://store.playstation.com/valkyrie-api/en/us/999/resolve/{}?depth=999'.format(
- x.parent['href'].split('/')[-1])).content)
- break
- except Exception:
- pass
- if type(y['included']) is list:
- for inc in y['included']:
- try:
- if inc['attributes']['file-size']['value'] is not None:
- if inc['attributes']['file-size']['unit'] == 'MB':
- total += int(inc['attributes']['file-size']['value']) * 1024 * 1024
- elif inc['attributes']['file-size']['unit'] == 'GB':
- total += int(inc['attributes']['file-size']['value']) * 1024 * 1024 * 1024
- elif inc['attributes']['file-size']['unit'] == 'KB':
- total += int(inc['attributes']['file-size']['value']) * 1024
- print(
- "{} {}".format(inc['attributes']['file-size']['value'], inc['attributes']['file-size']['unit']))
- except KeyError:
- pass
- else:
- if y['included']['attributes']['file-size']['value'] is not None:
- if y['included']['attributes']['file-size']['unit'] == 'MB':
- total += int(y['included']['attributes']['file-size']['value']) * 1024 * 1024
- elif y['included']['attributes']['file-size']['unit'] == 'GB':
- total += int(y['included']['attributes']['file-size']['value']) * 1024 * 1024 * 1024
- elif y['included']['attributes']['file-size']['unit'] == 'KB':
- total += int(y['included']['attributes']['file-size']['value']) * 1024
- print("{} {}".format(y['included']['attributes']['file-size']['value'],
- y['included']['attributes']['file-size']['unit']))
- print("Current TOTAL: {}".format(total))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement