A tool to scrape and download publicly available stock information. Currently supports Yahoo Finance data.
Project description
Finance Scrapers
A pypi package to scrape stock information from different finance sites. Currently supports Yahoo Finance.
Installation
To install, Download the PyPi package or,
pip install finance-scrapers
To upgrade to the latest version,
pip install --upgrade finance-scrapers
Usage
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)
all_stock_info = scraper.stock_info
Scrape stock information and display to terminal:
from finance_scrapers import YahooFinance
# the tickers of the stocks you want to scrape
tickers = ['schb', 'googl', 'nflx']
# display data found from stocks
scraper = YahooFinance(tickers)
scraper.display_data()
# display custom data
sample_data = {"name": "Mandy-cyber", "love": "food"}
scraper.display(sample_data)
Example
{
"AXP": {
"Ask": "171.39 x 800",
"PE Ratio (TTM)": "17.95",
"Open": "172.17",
"Earnings Date": "Jul 21, 2023",
"Volume": "Jul 06, 2023",
"Market Cap": "127.169B",
"Avg. Volume": "186.00",
"52 Week Range": "130.65 - 182.15",
"Forward Dividend & Yield": "2.40 (1.36%)",
"Day's Range": "167.42 - 173.34",
"Previous Close": "177.11",
"EPS (TTM)": "9.53",
"Bid": "171.28 x 1000"
},
"SCHB": {
"Ask": "53.07 x 1000",
"PE Ratio (TTM)": "21.73",
"Open": "53.12",
"YTD Daily Total Return": "18.99%",
"Volume": "0.03%",
"Net Assets": "23B",
"Avg. Volume": "2009-11-03",
"52 Week Range": "40.92 - 53.43",
"Beta (5Y Monthly)": "1.01",
"Day's Range": "52.88 - 53.12",
"Previous Close": "52.92",
"Yield": "1.47%",
"Bid": "53.06 x 2200"
},
"NKE": {
"Ask": "108.85 x 1800",
"PE Ratio (TTM)": "33.80",
"Open": "108.00",
"Earnings Date": "Sep 27, 2023 - Oct 02, 2023",
"Volume": "Jun 02, 2023",
"Market Cap": "167.816B",
"Avg. Volume": "127.70",
"52 Week Range": "82.22 - 131.31",
"Forward Dividend & Yield": "1.36 (1.26%)",
"Day's Range": "107.54 - 109.24",
"Previous Close": "107.53",
"EPS (TTM)": "3.23",
"Bid": "108.83 x 1200"
}
}
Scrape stock information and download to a file:
from finance_scrapers import YahooFinance
# the tickers of the stocks you want to scrape
tickers = ['schb', 'googl', 'nflx']
scraper = YahooFinance(tickers)
# download data
scraper.download_data(file_type="json", file_path="sample.json", overwrite=False) # or,
scraper.download_data("markdown", "sample.md") # or,
scraper.download_data("csv", "sample.csv") # or,
scraper.download_data("excel", "sample.xlsx")
Examples of these downloads can be found here
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
finance-scrapers-1.1.5.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for finance_scrapers-1.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5575c0a7e2f08009f93c50af02811d976781178aa4797e31ba2a31eaf77fa0f |
|
MD5 | 4eed6d175bddea07ec12326c2f43766a |
|
BLAKE2b-256 | fe6ec71594fcb4d9e5170f550b07c568b47e9bc960320edb7f74017eabc103f2 |