Answer a question

I want to get this number (dollar price) auto buy price.

def get_auto_buy_price(self):
        id = 35650 # specital number for items
        url = f"https://buff.163.com/goods/{id}?from=market#tab=buying"
        html = requests.get(url)
        soup = BeautifulSoup(html.text, "lxml")
        print(soup.find_all("div", "detail-tab-cont"))

With this code I can get where buff163 contains tables with prices but it's empty.

Answers

Because the webpage is dynamic and data is populating from external source via API. Only requests module can grab data from API url.

import requests
res= requests.get('https://buff.163.com/api/market/goods/buy_order?game=csgo&goods_id=35650&page_num=1&_=1657808768032').json()

for price in res['data']['items']:
    print(price['price'])

Output:

1.2
1.1
1
1
1
0.8
0.1

API_SCREENSHOT

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐