0

我一直在挣扎一段时间,试图找到如何以某种方式让它更快

编码

def get_resellers(sellerid, price, userassetid, id):
    data = {"expectedCurrency":1,"expectedPrice":price, "expectedSellerId":sellerid,"userAssetId":userassetid}
    headers = {"X-CSRF-TOKEN":csrftoken}
    k = requests.post(f"https://economy.roblox.com/v1/purchases/products/{id}", data=data, headers=headers, cookies=cookies)

def check_price(id):
    while True:
        try:
            t0 = time.time()
            soup = BeautifulSoup(requests.get(f"https://www.roblox.com/catalog/{id}").content, 'html.parser')
            data_expected_price, data_expected_seller_id, data_userasset_id = soup.select_one('[data-expected-price]')['data-expected-price'], soup.select_one('[data-expected-seller-id]')['data-expected-seller-id'], soup.select_one('[data-lowest-private-sale-userasset-id]')['data-lowest-private-sale-userasset-id']
            t1 = time.time()
            total = t1 - t0
            print(total)
            if int(data_expected_price) < 0.7*int(data_expected_price):
                    get_resellers(data_expected_seller_id, data_expected_price, data_userasset_id, id)
        except:
                pass

有没有更快的方法来完成它或提取这些东西,或者发出 http 请求等。任何事情都可以提供帮助!另外:购买和价格检查需要 0.7 秒,因为它每次都需要加载网站,是否有更快的速度?

4

0 回答 0