A pypi package to scrape stock information from different finance sites. Currently supports Yahoo Finance.
To install, Download the PyPi package or,
pip install finance-scrapers
To upgrade to the latest version,
pip install --upgrade finance-scrapers
Scrape stock information:
from finance_scrapers import YahooFinance
# the tickers of the stocks you want to scrape
tickers = ['schb', 'googl', 'nflx']
# run the scraper
scraper = YahooFinance(tickers)
scraper.run()
all_stock_info = scraper.all_stock_info
Scrape stock information and download to a file:
from finance_scrapers import YahooFinance, Downloader
# the tickers of the stocks you want to scrape
tickers = ['schb', 'googl', 'nflx']
# run the scraper
scraper = YahooFinance(tickers)
scraper.run()
# download data
Downloader.download_csv(data=scraper.all_stock_info, file_path='../samples/data.csv')
Downloader.download_excel(data=scraper.all_stock_info, file_path='../samples/data.xlsx')
Downloader.download_json(data=scraper.all_stock_info, file_path='../samples/data.json')
Downloader.download_md(data=scraper.all_stock_info, file_path='../samples/data.md')
Examples of these downloads can be found here