Advertisement
ku_

Roblox Sub Place Extractor (Python 3.12.1)

ku_
Jan 12th, 2024
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. import requests
  2.  
  3. placeId = 9472371402 # The Backrooms [REDACTED] / Set this to the Place ID you want to get sub places for
  4. r = requests.get('https://apis.roblox.com/universes/v1/places/{}/universe'.format(placeId), headers={'User-Agent':'Roblox/WinInet (Kuromian Device)'})
  5. universeId = r.json()['universeId']
  6. places_url = f'https://develop.roblox.com/v1/universes/{universeId}/places'
  7. cursor = ''
  8. first_request = True
  9.  
  10. places_response = requests.get(places_url)
  11. places_data = places_response.json()
  12. place_name_page = places_data['data'][0]['name']
  13.  
  14. while True:
  15.     if first_request:
  16.         url = places_url
  17.         first_request = False
  18.     else:
  19.         url = f'{places_url}?cursor={cursor}'
  20.     places_response = requests.get(url)
  21.     places_data = places_response.json()
  22.     if places_response.status_code == 200:
  23.         places = places_data['data']
  24.         for place in places:
  25.             place_id = place['id']
  26.             with open(f'{place_name_page}.txt', 'a+', encoding='utf8') as f:
  27.                 place_name = place['name']
  28.                 f.write(f'Place ID: {place_id}, Place Name: {place_name}\n')
  29.             print('Place ID:', place_id)
  30.             print('Name:', place_name)
  31.             print('------------')
  32.         if not places_data['nextPageCursor']:
  33.             break
  34.         else:
  35.             cursor = places_data['nextPageCursor']
  36.     else:
  37.         print('Error:', places_response.status_code)
  38.         exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement