I am trying to buy an item with the Roblox API in Python. However I am having trouble finding the link to make a post request to purchase an item. Here is my code so far:
def buyItem(self,itemid, cookie):
info = self.getItemInfo(itemid)
url="https://api.roblox.com/item.ashx?rqtype=purchase&productID={}&expectedCurrency=1&expectedPrice={}&expectedSellerID={}&userAssetID=".format(info["ProductId"], 0 if info["PriceInRobux"] == None else info["PriceInRobux"],info["Creator"]["Id"])
print(url)
cookies = {
'.ROBLOSECURITY': cookie
}
headers = {
'X-CSRF-TOKEN': self.setXsrfToken(cookie)
}
r = self.s.post(url, cookies=cookies, headers=headers)
print(r.status_code)
return r
I get 400 errors and the error code is:
{"errors":[{"code":400,"message":"BadRequest"}]}
I just need to figure out the correct URL to send the post request to. Help is appreciated! Thanks!
I recommend using selenium!
the reason for this is because it is much simpler!
Example code for buying an item with selenium:
from time import sleep as wait
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.roblox.com/catalog/139152472/Holiday-Crown") ##opens the link
wait(30) ## gives you 30 seconds to sign in before the script runs!
driver.find_element_by_class("btn-fixed-width-lg btn-growth-lg PurchaseButton").click()## clicks the element it finds with that class
driver.find_element_by_id("confirm-btn").click() ##clciks the the comfirm button
If you need a little bit of help heres meh discord: Encryptal#3233
Heres my roblox account: Encryptal
Im learning this to so i could help you out and explain it! :D