Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Realtime-yahoo-stock_price

from bs4 import BeautifulSoup
import requests


url = 'https://finance.yahoo.com/quote/VTSAX?p=VTSAX&.tsrc=fin-srch'
page = requests.get(url, headers={
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
})
soup = BeautifulSoup(page.text, 'html.parser')
price = soup.find('fin-streamer', {'class': 'Fw(b) Fz(36px) Mb(-4px) D(ib)'}).text

print(price)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
2+3 =