Reputation: 1
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
page = uReq ("https://www.binance.com/en")
data_1 = soup(page, 'html.parser')
a = data_1.body.div.main.find("div", class_="sc-bdVaJa bfHstm").table.find_all("div", class_="sc-bdVaJa dvJpRY")
print(a)
I am relatively new to beautiful soup, and i was trying to extract the price from binance website but i cant seem to select past the table to get to the price of bitcoin. Any help will be much appreciated. Thanks!
Upvotes: 0
Views: 60
Reputation: 8405
You cannot extract this data from the page, because it's not actually part of the page that is returned when you request this url. All of the price data there is added in dynamically by javascript after the page is loaded. In order to extract this data from the page, you would need to first execute the javascript and then read those div
s after they've actually been created, and BeautifulSoup is not meant to do this, and is not capable of it. It is only for analyzing static html/xml
If you want to query price listings from binance, you could use this python-binance package. This get_all_tickers
function is probably what you're after
Returns: List of market tickers
[
{
"symbol": "LTCBTC",
"price": "4.00000200"
},
{
"symbol": "ETHBTC",
"price": "0.07946600"
}
]
Upvotes: 3