Python na rynku giełdowym

"""you can use BeautifulSoup as webscraper"""
import requests
from bs4 import BeautifulSoup


def get_value(target):
    URL = f'https://finance.yahoo.com/quote/{target}'
    page = requests.get(URL)

    soup = BeautifulSoup(page.content, 'html.parser')
    product = soup.find('div', {"id": "mrt-node-Lead-4-QuoteHeader"})
    value = product.find('fin-streamer', {"data-field": "regularMarketPrice", "data-pricehint": "2"})["value"]
    change = product.find('fin-streamer', {"data-field": "regularMarketChange", "data-pricehint": "2"})["value"]
    change_pct = product.find('fin-streamer',
                              {"data-field": "regularMarketChangePercent", "data-pricehint": "2"})["value"]
    return value, change, change_pct


print(get_value("ETH-USD"))

"""else you can use the yfinace module"""
import yfinance as yf
data = yf.download(tickers='PROX.BR', period='1w', interval='1d')
print(data)
Gifted Gannet