Created
May 19, 2017 06:52
-
-
Save Krewn/0e624d35c396df63262dd42d74f2beb6 to your computer and use it in GitHub Desktop.
Get Stock quotes from Yahoo finance pages in python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where are the results (price quotes) stored.