Python Roblox问题,购买有限的物品
所以在roblox中,我试图向他们的api发送购买物品的请求。代码如下:Python Roblox问题,购买有限的物品,python,request,python-requests,roblox,Python,Request,Python Requests,Roblox,所以在roblox中,我试图向他们的api发送购买物品的请求。代码如下: 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
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
当我尝试在一件5 robux衬衫上运行buyItem函数时,它毫无问题地买下了它。但后来我想买一个有限的,它不买。同样是的,有足够的机器人。谢谢你的帮助!谢谢 我在github上查找它,发现了类似的东西。我想这会对你有帮助。对不起,回复太长了。 我认为可能需要额外的参数,见第370行
post("https://web.roblox.com/api/item.ashx?rqtype=purchase&productID={}
&expectedCurrency=1
&expectedPrice={}
&expectedSellerID={}
&userAssetID={}".format(
self.getItemInfo(
aid['ProductId'],
seller['Price'],
seller['SellerId'],
seller['UserAssetId']),
headers = {"X-CSRF-TOKEN":self.token})