简体   繁体   中英

Using python pandas's Datareader for yahoo finance's key statistic web page vs default yahoo's finance's historial prices web page

I am trying to use python's Pandas library for data scraping from yahoo finance to pull data from it's historical prices using DataReader from pandas, but I also want to pull data from yahoo finance from it's Key statistic web page like "price/book ratio". But I am not sure how to modify DataReader to pull data other than historical prices.

I would like to use pandas library to do all my web scraping, is there different functions in pandas for me to pull data for different web page of yahoo finance or modify DataReader function to pull other data? like saving all in HTML?

There is python yahoo-finance module . You can look there for data you want.

Additionally you can build request function:

def __request(symbol, stat):
    url = 'http://finance.yahoo.com/d/quotes.csv?s=%s&f=%s' % (symbol, stat)
    return urllib.urlopen(url).read().strip().strip('"')

Use it to get data you need. For example, last price:

def get_price(symbol): 
    return __request(symbol, 'l1')

Here is list with other fields you can extract.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM