Advertisement
Guest User

Untitled

a guest
Jan 29th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.43 KB | None | 0 0
  1. # --MODULES--
  2. # -colorama module to print colors into terminal
  3. # -imports sleep from time
  4. # -pip install requests **sends requests**
  5. # -built in module for time: sleep, count, etc..
  6. # -system processes **built in module from python to communicate with the interpreter**
  7. # -pip install termcolor **color module for terminal output**
  8. try:
  9. import colorama
  10. import requests
  11. import time
  12. import sys
  13. import os
  14. import datetime
  15. from termcolor import *
  16. from time import sleep
  17. from io import StringIO
  18. from bs4 import BeautifulSoup
  19. finally:
  20. print('')
  21.  
  22.  
  23. desc0 = open('description.txt', 'r').read()
  24. prc0 = open('price.txt', 'r').read()
  25. grp0 = open('group.txt', 'r').read()
  26. acc0 = open('username.txt', 'r').read()
  27. acc1 = open('password.txt', 'r').read()
  28.  
  29. # start of class object
  30. # class name for calling variables easily
  31. class ColeBotPublic(object):
  32. # defined function inside of class(using .self)
  33. def __init__(self, group_id, price, description):
  34. # creates a browser session, **emulates a mobzilla browser, will function properly on linux/unix OS's. *NOTE* you will need mobzilla installed.*
  35. self.headers = {}
  36. # requests session
  37. self.session = requests.session()
  38. # updates the headers of the session
  39. self.session.headers.update(self.headers)
  40. # sets group id
  41. self.group_id = group_id
  42. # calling price object
  43. self.price = price
  44. self.description = description
  45. # checks if program is able to connect to the network
  46. if requests.get('https://pastebin.com/raw/L69v0yYC').text != 'Connection Check 2.1':
  47. # exits the script, and sends the message, "Network has Shutdown..."
  48. sys.exit(colored('Network has Shutdown, check your NIC for more infomation. *Tip* / Try restarting your router.', 'red', attrs=['bold']))
  49. # creating a function taking two arguments
  50.  
  51. def login(self, username, password):
  52. # prints out a string 'Login'
  53. print(colored('Login Beginning...', 'yellow', attrs=['bold']))
  54. # logs into roblox with the raw input sending a payload
  55. payload = {'username': username, 'password': password}
  56. # uses the session and payload to send a request
  57. self.session.post('https://www.roblox.com/newlogin', data=payload)
  58. # prints a 'Logged' in string
  59. print('Welcome;', username)
  60.  
  61. # creating a function taking three arguments
  62. def get_shirts(self, starting_page=890, category='12', wait=10):
  63. # the starting page of the bot
  64. page_num = starting_page
  65. # taking a while logical statement
  66. while page_num < 999999:
  67. # takes the id of the shirt/item
  68. params = {'CatalogContext': '890', 'Subcategory': category, 'SortAggregation': '5', 'LegendExpanded': 'true', 'Category': '3', 'PageNumber': page_num}
  69. # try logical statement
  70. try:
  71. # requests a session in catalog
  72. r = self.session.get('https://www.roblox.com/catalog/json', params=params)
  73. # json/html code
  74. r.raise_for_status()
  75. # json/html code
  76. except requests.exceptions.HTTPError:
  77. # json/html code
  78. print(colored('Status Error', 'red'))
  79. # json/html code
  80. time.sleep(30)
  81. # continue logic statment
  82. continue
  83. # prints the number of items on a page
  84. print(colored('Received items from page', 'cyan'))
  85. # iterates through the asset and json file
  86. for asset in r.json():
  87. # calls a download for the item
  88. self.__download(asset['AssetId'])
  89. # sleep/wait function
  90. time.sleep(wait)
  91. # if page_num is not equal to 1
  92. page_num += 1
  93.  
  94. # defining a function taking one argument
  95. def __download(self, asset_id):
  96. # finds the name, desc and price for the item
  97. data = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': asset_id})
  98. # gets the session from the api
  99. try:
  100. # converting data to json
  101. data = data.json()
  102. except ValueError:
  103. return
  104. # finds all the data
  105. name, description, price, asset_type = data['Name'], data['Description'], data['PriceInRobux'], data['AssetTypeId']
  106. # gets templates asset id
  107. count = 0
  108. # while counting less than 10
  109. while count < 10:
  110. # if asset id less than equal to 1
  111. asset_id -= 1
  112. # try statement
  113. try:
  114. # finds product info
  115. r = self.session.get('https://api.roblox.com/Marketplace/ProductInfo', params={'assetId': asset_id})
  116. # counts, more than equal to 1
  117. count += 1
  118. # adding two functions
  119. r.raise_for_status()
  120. # if function.json(), Name.str() ='s to the variable name
  121. if r.json()['Name'] == name:
  122. # prints a response function
  123. print(colored('Received the template id', 'green'))
  124. # breaks the loop
  125. break
  126. # except the HTTP error, if not found, complete the loop
  127. except (requests.exceptions.HTTPError, ValueError):
  128. # prints a response function
  129. print(colored('ID isn\'t found', 'red'))
  130. # returns the function
  131. return
  132. # else statement
  133. else:
  134. # prints a response function
  135. print(colored('Could not find template', 'magenta'))
  136. # returns the function one last time
  137. return
  138. # downloads file to memory for later upload
  139. file = self.session.get('https://www.roblox.com/asset/', params={'id': asset_id})
  140. # print function
  141. print(colored('Downloaded Template', 'yellow'))
  142. # calling arguments inside of the class
  143. self.upload(name, file, asset_type, asset_id)
  144.  
  145. # creates new function
  146. def upload(self, name, file, asset_type, asset_id):
  147. # gets verification token
  148. r = self.session.get('https://www.roblox.com/build/upload')
  149. # requests for token, from ROBLOX
  150. token = r.text.split('name=__RequestVerificationToken type=hidden value=')[-1].split('>')[0]
  151. # print function
  152. print(colored('Got tRequest Verification Token', 'yellow'))
  153. # uploads file to Roblox
  154. data = {'file': ('template.png', file.content, 'image/png')}
  155. # creates a payload with the token requesting access the the session
  156. payload = {'__RequestVerificationToken': token, 'assetTypeId': asset_type, 'isOggUploadEnabled': 'True', 'isTgaUploadEnabled': 'True', 'groupId': self.group_id, 'onVerificationPage': 'False', 'name': name}
  157. # requests a session to the url, 'https://www.roblox.com/build/upload', **goes to the json page**
  158. r = self.session.post('https://www.roblox.com/build/upload', files=data, data=payload)
  159. # gets asset id so the shirt can be published
  160. fix = r.text.split('<a href="https://www.roblox.com/catalog/')
  161. # if length of fix doesn't equal 2, then
  162. if len(fix) >= 2:
  163. # splits the session of the json/html url
  164. asset_id = r.text.split('<a href="https://www.roblox.com/catalog/')[1]
  165. # slices the url from /
  166. asset_id = asset_id.split('/')[0]
  167. # simple else statement,
  168. else:
  169. # print function with termcolor
  170. print(colored(" {{/--Something Wrong--\}}" * 1, 'red', attrs=['bold']))
  171. # returns the function
  172. return
  173. # creating new variable containing a dictionary
  174. assets = {'id': asset_id}
  175. # gets required fields for post request
  176. r = self.session.get('https://www.roblox.com/my/item.aspx', params=assets)
  177. # creates new variable with API inside
  178. view_state = r.text.split('id="__VIEWSTATE" value="')[-1].split('" />')[0]
  179. # creates new variable with a API inside
  180. view_gen = r.text.split('id="__VIEWSTATEGENERATOR" value="')[-1].split('" />')[0]
  181. # creates new variable with a API inside
  182. validation = r.text.split('id="__EVENTVALIDATION" value="')[-1].split('" />')[0]
  183. # creates payload for shirt editing/publishing
  184. payload = {'__EVENTTARGET': 'ctl00$cphRoblox$SubmitButtonBottom', '__EVENTARGUMENT': '', '__VIEWSTATE': view_state, '__VIEWSTATEGENERATOR': view_gen, '__EVENTVALIDATION': validation, 'ctl00$cphRoblox$NameTextBox': name, 'ctl00$cphRoblox$DescriptionTextBox': self.description, 'ctl00$cphRoblox$SellThisItemCheckBox': 'on', 'ctl00$cphRoblox$SellForRobux': 'on', 'ctl00$cphRoblox$RobuxPrice': self.price, 'ctl00$cphRoblox$EnableCommentsCheckBox': 'on', 'GenreButtons2': '1', 'ctl00$cphRoblox$actualGenreSelection': '1'}
  185. # claims class, then creates a post request containing a payload
  186. (self.session.post('https://www.roblox.com/my/item.aspx', params=assets, data=payload))
  187. # print function with the asset id
  188. print(colored('Uploaded File: {}', 'green'.format(asset_id)))
  189.  
  190.  
  191. if __name__ == '__main__':
  192.  
  193. r0 = requests.get('https://pastebin.com/raw/mzj7XBWy').content
  194. r1 = requests.get('https://pastebin.com/raw/AdHiGSgA').content
  195. print(colored('=' * 99, 'green'))
  196. print(colored(r0 + r1, 'green'))
  197. print(colored('=' * 99, 'green'))
  198. print(colored('<<< Authorizing Account >>>', 'white', attrs=['bold']))
  199. print(colored('=' * 99, 'green'))
  200.  
  201. reference = ColeBotPublic(group_id=grp0, price=prc0, description=desc0)
  202. reference.login(username=acc0, password=acc1)
  203. reference.get_shirts(starting_page=10, category='12', wait=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement