Advertisement
Guest User

zee new

a guest
Oct 5th, 2018
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.82 KB | None | 0 0
  1. import requests
  2. import time
  3. import sys
  4.  
  5. from uuid import getnode as get_mac
  6. mac = get_mac()
  7.  
  8. print (mac)
  9.  
  10. class RobloxBot:
  11.         """A simple Roblox bot class"""
  12.         def __init__(self, group_id):
  13.                 # creates a session
  14.                 self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
  15.                 self.session = requests.session()
  16.                 self.session.headers.update(self.headers)
  17.                 # sets group id
  18.                 self.group_id = group_id
  19.                 # checks if program is able to connect
  20.                 if requests.get('https://pastebin.com/raw/iRDJv57z').text != 'OK':
  21.                         sys.exit('Unable to connect')
  22.  
  23.         def login(self, username, password):
  24.                 print('Logging In...')
  25.                 # logs into Roblox with the provided username and password
  26.                 payload = {'username': username, 'password': password}
  27.                 self.session.post('https://api.roblox.com/v2/login', data=payload)
  28.                 print('Successfully Logged In.')
  29.  
  30.         def search(self, CatalogContext = 1, PageNumber = 1, Subcategory = '', Category = '', SortType = '', AggregationFrequency = '', Keyword = ''):
  31.             """simple catalog search"""
  32.             queryString = {}
  33.             for key, value in locals().items():
  34.                 if (key != 'self' and key != 'queryString' and value != ''):
  35.                     queryString[key] = value
  36.                 queryString = urlencode(queryString)
  37.                 searchUrl = 'https://search.roblox.com/catalog/json?{}'.format(queryString)
  38.                 try:
  39.                     request = requests.get(searchUrl.format(queryString))
  40.                     if (request.status_code == 200):
  41.                         return request.json()
  42.                 except:
  43.                     pass
  44.                 return {}
  45.    
  46.         def getData(self, assetId):
  47.             """gets data for asset"""
  48.             assetUrl = 'https://assetgame.roblox.com/asset/?id={}'
  49.             try:
  50.                 request = requests.get(assetUrl.format(assetId))
  51.                 if (request.status_code == 200):
  52.                     soup = BeautifulSoup(request.content)
  53.                     return soup
  54.             except:
  55.                 pass
  56.  
  57.         def __download(self, assetId):
  58.                 # gets name, description, price and file
  59.                 data = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': assetId})
  60.                 try:
  61.                         data= data.json()
  62.                 except ValueError:
  63.                         return
  64.  
  65.                 #old code (commented out below)
  66.                 name, description, price, asset_type = data['Name'], data['Description'], data['PriceInRobux'], data['AssetTypeId']
  67.                
  68.        
  69.                 # gets templates asset id
  70.                 count = 0
  71.                 while count < 10:
  72.                         assetId -= 1
  73.                         try:
  74.                                 r = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': assetId})
  75.                                 count += 1
  76.                                 r.raise_for_status()
  77.                                 if r.json()['Name'] == name:
  78.                                         print('Got template id for: {}'.format(assetId))
  79.                                         break
  80.                         except (requests.exceptions.HTTPError, ValueError):
  81.                                 print('Could not find template for: {}'.format(assetId))
  82.                                 return
  83.                 else:
  84.                         print('Could not find template for: {}'.format(assetId))
  85.                         return
  86.                 # downloads file to memory for later upload
  87.                 file = self.session.get('https://www.roblox.com/asset/', params={'id': assetId})
  88.                 print('Downloaded Template.')
  89.                 self.__upload(name, description, price, file, asset_type, assetId)
  90.  
  91.         def __upload(self, name, description, price, file, asset_type, assetId):
  92.                 # gets verification token
  93.                 r = self.session.get('https://www.roblox.com/build/upload')
  94.                 token = r.text.split('name=__RequestVerificationToken type=hidden value=')[-1].split('>')[0]
  95.                 print('Got Request Verification Token.')
  96.                 # uploads file to Roblox
  97.                 data = {'file': ('template.png', file.content, 'image/png')}
  98.                 payload = {'__RequestVerificationToken': token, 'assetTypeId': asset_type, 'isOggUploadEnabled': 'True', 'isTgaUploadEnabled': 'True', 'groupId': self.group_id, 'onVerificationPage': 'False', 'name': name}
  99.                 r = self.session.post('https://www.roblox.com/build/upload', files=data, data=payload)
  100.                 # gets asset id so the shirt can be published
  101.                 fix = r.text.split('<a href="https://www.roblox.com/catalog/')
  102.                
  103.                 if len(fix) >= 2:
  104.                         asset_id = r.text.split('<a href="https://www.roblox.com/catalog/')[1]
  105.                         asset_id = asset_id.split('/')[0]
  106.                 else:
  107.                         print("Error!")
  108.                         return
  109.                 assets = {'id': asset_id}
  110.                 # gets required fields for post request
  111.                 r = self.session.get('https://www.roblox.com/my/item.aspx', params=assets)
  112.                 view_state = r.text.split('id="__VIEWSTATE" value="')[-1].split('" />')[0]
  113.                 view_gen = r.text.split('id="__VIEWSTATEGENERATOR" value="')[-1].split('" />')[0]
  114.                 validation = r.text.split('id="__EVENTVALIDATION" value="')[-1].split('" />')[0]
  115.                 # creates payload for shirt editing/publishing
  116.                 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'}
  117.                 self.session.post('https://www.roblox.com/my/item.aspx', params=assets, data=payload)
  118.                 print('Successfully Uploaded: {}'.format(assetId))
  119.  
  120. if __name__ == '__main__':
  121.         # instantiates RobloxBot
  122.         bot = RobloxBot(group_id='')
  123.         # logs into Roblox
  124.         bot.login(username='', password='')
  125.         # starts collecting shirts on page one with a wait time of 10 seconds
  126.         bot.get_shirts(starting_page=1210, category='12', wait=2.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement