Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

stock market python

"""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)
Comment

PREVIOUS NEXT
Code Example
Python :: Customizing scatter plot with pyplot object 
Python :: python unittest multiple test cases 
Python :: pandas change string column to datetime 
Python :: str remove except alphabets 
Python :: sort dictionary by key python 
Python :: remove list from list python 
Python :: override get_queryset django with url parameters 
Python :: numpy flatten along two axes 
Python :: how to save python-pptx 
Python :: how to backspace in python 
Python :: python colored text in console 
Python :: Python RegEx SubString – re.sub() 
Python :: image data generator tensorflow 
Python :: DecisionTreeClassifier 
Python :: python linear interpolation 
Python :: or en python 
Python :: retry on exception python 
Python :: .unique() python 
Python :: Generate hashed passwords for ansible 
Python :: csrf token django 
Python :: python how to invert an array 
Python :: new paragraph python 
Python :: how to define a functio in python 
Python :: tkinter convert Entry to string 
Python :: Python NumPy insert Function Syntax 
Python :: model.predict python 
Python :: python variables 
Python :: read excel file in computer 
Python :: Check version of package poetry 
Python :: python basics flask project 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =