Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. import requests
  2. import time
  3. import sys
  4. import os
  5. os.system("color 0A")
  6.  
  7. print('Intialising')
  8. name= input (" Admin Access or Trial Access? ")
  9. print("Accessing " + name + " Priviliges... ")
  10.  
  11.  
  12.  
  13.  
  14. class RobloxBot:
  15. """A simple Roblox bot class"""
  16. def __init__(self, group_id):
  17. # creates a session
  18. self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
  19. self.session = requests.session()
  20. self.session.headers.update(self.headers)
  21. # sets group id
  22. self.group_id = group_id
  23. # checks if program is able to connect
  24. if requests.get('https://pastebin.com/raw/iRDJv57z').text != 'OK':
  25. sys.exit('Unable to connect')
  26.  
  27. def login(self, username, password):
  28. print('Attempting to login to the account you have provided... ')
  29. # logs into Roblox with the provided username and password
  30. payload = {'username': username, 'password': password}
  31. self.session.post('https://www.roblox.com/newlogin', data=payload)
  32. print('I have been successfully able to access into the account.')
  33.  
  34. def get_shirts(self, starting_page=66, category='12', wait=10):
  35. page_num = starting_page
  36. while page_num < 999999:
  37. # gets asset ids of shirts
  38. params = {'CatalogContext': 66, 'Subcategory': category, 'SortAggregation': '5', 'LegendExpanded': 'true', 'Category': '3', 'PageNumber': page_num}
  39. try:
  40. r = self.session.get('https://www.roblox.com/catalog/json', params=params)
  41. r.raise_for_status()
  42. except requests.exceptions.HTTPError:
  43. print('Status Error: {}'.format(r.status_code))
  44. time.sleep(30)
  45. continue
  46. print('Got items from page: {}'.format(page_num))
  47. # iterates through json and grabs asset ids from page
  48. for asset in r.json():
  49. # calls download with the asset id
  50. while True:
  51. try:
  52. self.__download(asset['AssetId'])
  53. break
  54. except:
  55. print('There has been an error, retrying.')
  56. continue
  57. time.sleep(wait)
  58. page_num += 1
  59.  
  60. def __download(self, assetId):
  61. # gets name, description, price and file
  62. data = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': assetId}).json()
  63. name, description, price, asset_type = data['Name'], data['Description'], data['PriceInRobux'], data['AssetTypeId']
  64. # gets templates asset id
  65. count = 0
  66. while count < 10:
  67. assetId -= 1
  68. try:
  69. r = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': assetId})
  70. count += 1
  71. r.raise_for_status()
  72. if r.json()['Name'] == name:
  73. print('Okay, I have got the shirt')
  74. break
  75. except (requests.exceptions.HTTPError, ValueError):
  76. print('Oh dear, there has been an error retrieving the shirt')
  77. return
  78. else:
  79. print('Oh dear, there has been an error retrieving the shirt')
  80. return
  81. # downloads file to memory for later upload
  82. file = self.session.get('https://www.roblox.com/asset/', params={'id': assetId})
  83. print('Downloaded Template.')
  84. self.__upload(name, description, price, file, asset_type, assetId)
  85.  
  86. def __upload(self, name, description, price, file, asset_type, assetId):
  87. # gets verification token
  88. r = self.session.get('https://www.roblox.com/build/upload')
  89. token = r.text.split('name=__RequestVerificationToken type=hidden value=')[-1].split('>')[0]
  90. print('Got Request Verification Token.')
  91. # uploads file to Roblox
  92. data = {'file': ('template.png', file.content, 'image/png')}
  93. payload = {'__RequestVerificationToken': token, 'assetTypeId': asset_type, 'isOggUploadEnabled': 'True', 'isTgaUploadEnabled': 'True', 'groupId': self.group_id, 'onVerificationPage': 'False', 'name': name}
  94. r = self.session.post('https://www.roblox.com/build/upload', files=data, data=payload)
  95. # gets asset id so the shirt can be published
  96. asset_id = r.text.split('uploadedId=')[-1].split('" />')[0]
  97. assets = {'id': asset_id}
  98. # gets required fields for post request
  99. r = self.session.get('https://www.roblox.com/my/item.aspx', params=assets)
  100. view_state = r.text.split('id="__VIEWSTATE" value="')[-1].split('" />')[0]
  101. view_gen = r.text.split('id="__VIEWSTATEGENERATOR" value="')[-1].split('" />')[0]
  102. validation = r.text.split('id="__EVENTVALIDATION" value="')[-1].split('" />')[0]
  103. # creates payload for shirt editing/publishing
  104. payload = {'__EVENTTARGET': 'ctl00$cphRoblox$SubmitButtonBottom', '__EVENTARGUMENT': '', '__VIEWSTATE': view_state, '__VIEWSTATEGENERATOR': view_gen, '__EVENTVALIDATION': validation, 'ctl00$cphRoblox$NameTextBox': name, 'ctl00$cphRoblox$DescriptionTextBox': description, 'ctl00$cphRoblox$SellThisItemCheckBox': 'on', 'ctl00$cphRoblox$SellForRobux': 'on', 'ctl00$cphRoblox$RobuxPrice': price, 'ctl00$cphRoblox$EnableCommentsCheckBox': 'on', 'GenreButtons2': '1', 'ctl00$cphRoblox$actualGenreSelection': '1'}
  105. self.session.post('https://www.roblox.com/my/item.aspx', params=assets, data=payload)
  106. print('I have been able to upload the shirt to your group, please wait a moment for it to appear in the store')
  107.  
  108. if __name__ == '__main__':
  109. # instantiates RobloxBot
  110. bot = RobloxBot(group_id='ur group id')
  111. # logs into Roblox
  112. bot.login(username='your name', password='ur pass')
  113. # starts collecting shirts on page one with a wait time of 10 seconds
  114. bot.get_shirts(starting_page=100, category='12', wait=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement