#python #python-requests #roblox #python-requests-html
Вопрос:
Я создал внешний сервер, который использовал для загрузки изображений в Roblox через серверный API. Но примерно со вчерашнего дня, поверьте, это произошло после отключения Roblox — он просто полностью перестал работать.
import requests import re import os from time import sleep import urllib3; urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) class DecalClass(): def __init__(self, cookie, location, name): self.goose = requests.Session() self.goose.cookies.update({ '.ROBLOSECURITY': cookie #set .ROBLOSECURITY cookie for authentication }) self.goose.headers.update({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134", #might as well use a User Agent }) self.location = location self.name = name def getToken(self): #get verification token function homeurl= 'https://www.roblox.com/build/upload' #this is the upload endpoint response = self.goose.get(homeurl, verify=False) try: veri = re.search('lt;input name=__RequestVerificationToken type=hidden value=(. ?)gt;', response.text).group(1) except: print("Error getting verification token (invalid cookie?)") return False return veri def upload(self): files = {'file': ('lol.png', open(self.location, 'rb'), 'image/png')} #add our image as files data data = { '__RequestVerificationToken': self.getToken(), 'assetTypeId': '13', #we use assetTypeId '13' because 13 is the id for Decals 'isOggUploadEnabled': 'True', 'isTgaUploadEnabled': 'True', 'onVerificationPage': "False", "captchaEnabled": "True", 'name': self.name } try: response = self.goose.post('https://www.roblox.com/build/upload', files=files, data=data) #make the request except: print("request is making error!") #here are the things you must change ROBLOSECURITY = "_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|lt;COOKIEWASHEREgt;" filelocation = "/content/cookie.png" #this is the directory to your image to upload. Note that the image must be in the same directory as this .py file. name = "yummy cookie" Decal = DecalClass(ROBLOSECURITY, filelocation, name) Decal.upload()
Что Я Пробовал?
Таким образом, проблема с токеном проверки на самом деле была исправлена после того, как я внедрил модуль HttpSession, а затем извлек запрос на проверку — В моем основном коде, но часть загрузки, похоже, просто не работает, даже если я сделал все то же самое.
Это на самом деле дает мне подсказку, похоже ли это на проблему с изменением Roblox, или я не передаю никаких заголовков и т. Д.?
Я на 100% уверен, что код работает почти с последних 2 недель, а затем он просто перестал работать вчера после отключения в конце Roblox — возможно, это просто случайность, не уверен.