This script will scrape Nasdaq.com to extract stock market data based on a ticker symbol of a company. If you would like to know more about this scraper you can check it out at this link https://www.scrapehero.com/scrape-nasdaq-stock-market-data/
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
This nasdaq scraper can extract the fields below
- Best Bid/Ask
- 1 Year Target
- Share Volume
- 50 Day Avg. Daily Volume
- Previous Close
- 52 Week High/Low
- Market Cap
- P/E Ratio 9.Forward P/E (1y)
- Earnings Per Share (EPS)
- Annualized Dividend
- Ex-Dividend Date
- Dividend Payment Date
- Current Yield
- Beta
- Open Price
- Open Date
- Close Price
- Close Date
For this web scraping tutorial using Python 3, we will need some packages for downloading and parsing the HTML. Below are the package requirements:
- lxml
- requests
PIP to install the following packages in Python (https://pip.pypa.io/en/stable/installing/)
Python Requests, to make requests and download the HTML content of the pages (http://docs.python-requests.org/en/master/user/install/)
Python LXML, for parsing the HTML Tree Structure using Xpaths (Learn how to install that here – http://lxml.de/installation.html)
We would execute the code with the script name followed by the ticker symbol of the company’s stock data you would like. As an example here is the command to find the summary data for Apple Inc.
python3 masdaq_finance.py aapl
This will create a json file: