Home > Mobile >  Python Web Scrapping
Python Web Scrapping

Time:08-07

I'm trying to write a code in Python that gets specific data from this site: exchange data

The information i'm interested in, is in the table at the middle of the page and I want to get the Price for each Q in the corresponding row. For example Q=0 price=18.9, Q=1 price = 19, etc.

Any suggestions how that can be done?

CodePudding user response:

You can get the desired data from API. Because data is loaded dynamically by JS via API.

import requests

api_url='https://simcotools.app/api/resource/18'

req=requests.get(api_url).json()

data=[]
for item in req['qualities']:
        Quantity = item['quality']
        Price = item['price']
        data.append({
              'Quantity':Quantity,
              'Price': Price
              })

print(data)

Output:

[{'Quantity': 0, 'Price': 18.8}, {'Quantity': 1, 'Price': 19.0}, {'Quantity': 2, 'Price': 19.1}, {'Quantity': 3, 'Price': 19.2}, {'Quantity': 4, 'Price': 19.3}, {'Quantity': 5, 'Price': 20.75}, {'Quantity': 6, 'Price': 23.5}, {'Quantity': 7, 'Price': 23.5}, {'Quantity': 8, 'Price': 39.0}, {'Quantity': 9, 'Price': 50.0}, {'Quantity': 10, 'Price': 100.0}]
  • Related