📜  给我 robux - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:14.929000             🧑  作者: Mango

代码示例2
def buyItem(self,itemid, cookie, price=None):
        info = self.getItemInfo(itemid)
        url="https://economy.roblox.com/v1/purchases/products/{}".format(info["ProductId"])
        print(url)
        cookies = {
            '.ROBLOSECURITY': cookie
        }
        headers = {
            'X-CSRF-TOKEN': self.setXsrfToken(cookie)
        }
        data={
            'expectedCurrency': 1, 'expectedPrice': info["PriceInRobux"] if price == None else price, 'expectedSellerId': info["Creator"]["Id"]
            }
        r = self.s.post(url, data=data, cookies=cookies, headers=headers)
        return r
def getItemInfo(self,itemid):
        return self.s.get("https://api.roblox.com/marketplace/productinfo?assetId="+str(itemid)).json()
def setXsrfToken(self, cookie):
        cookies = {
            '.ROBLOSECURITY': cookie
        }
        r = self.s.get("https://roblox.com/home", cookies=cookies)
        tok = r.text[r.text.find("Roblox.XsrfToken.setToken('") + 27::]
        tok = tok[:tok.find("');"):]
        return tok