Answer the question
In order to leave comments, you need to log in
Why is None returned when parsing?
You need to parse the bitcoin rate in real time. When the code is executed, None is returned, although there is such a class on the page and it is loaded immediately.
import requests
from bs4 import BeautifulSoup
url = 'https://www.tradingview.com/symbols/BTCUSD/?utm_campaign=tickers&utm_medium=widget&utm_source=xn----dtbfdbwspgnceulm.xn--p1ai'
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36 OPR/75.0.3969.259'}
source_code = requests.get(url, headers=HEADERS)
soup = BeautifulSoup(source_code.text, 'html.parser')
bitcoin_curse = soup.find('label', {'class': 'tab-HYHP1WHx tabSelected-HYHP1WHx'})
print(bitcoin_curse)
Answer the question
In order to leave comments, you need to log in
although there is such a class on the page and it is loaded immediately
wss://data.tradingview.com/socket.io/websocket?from=symbols%2FBTCUSD%2F&date=2021_05_06-10_12
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question