I want to scrape this website and get the price from it.
When I run my code I always get None
, I have tried with .find
and .find_all
but the result is always the same:
from bs4 import BeautifulSoup
import requests
r = requests.get('https://finance.yahoo.com/quote/BTC-USD?p=BTC-USD')
soup = BeautifulSoup(r.text, 'xml')
stock_price = soup.find('span', class_='Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)')
# I should get 8,531.30
print(stock_price)
I see that 'span', class_='Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)'
is dynamic, but then I have tried to get unique div thats above:
stock_price = soup.find_all('div', class_='D(ib) Va(m) Maw(65%) Ov(h)')
or:
stock_price = soup.find_all('div', class_='D(ib) Mend(20px)')
These 2 div
s are not dynamic, only two span
s inside them are dynamic, why cant I get my elements?
I have watched this tutorial and they do not use Chrome Selenium
https://www.youtube.com/watch?v=rONhdonaWUo
What am I doing wrong?