Skip to content

Instantly share code, notes, and snippets.

@Krewn
Created May 19, 2017 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Krewn/0e624d35c396df63262dd42d74f2beb6 to your computer and use it in GitHub Desktop.
Save Krewn/0e624d35c396df63262dd42d74f2beb6 to your computer and use it in GitHub Desktop.
Get Stock quotes from Yahoo finance pages in python.
import urllib.request
from bs4 import BeautifulSoup
def getPrice(tag):
source = "https://finance.yahoo.com/quote/"+tag
filehandle = urllib.request.urlopen(source)
soup = BeautifulSoup(filehandle.read(), "html.parser")
priceSpan = soup.findAll("span", { "class" : "Fz(36px)" })
for k in priceSpan:
return(k.getText())
def getDayChange(tag):
source = "https://finance.yahoo.com/quote/"+tag
filehandle = urllib.request.urlopen(source)
soup = BeautifulSoup(filehandle.read(), "html.parser")
priceSpan = soup.findAll("span", { "class" : "Fw(500)" })
for k in priceSpan:
return(k.getText())
@ali13571360
Copy link

where are the results (price quotes) stored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment