stockscraper
Introduction
Stock Ratio Scraper is a Python web scraping program designed to fetch financial ratios for various stocks from a specific website. It scrapes stock names and links and then retrieves financial ratios such as MarketCap, CurrentPrice, StockPE, and more. The fetched data is stored in separate text files for further analysis or reference.
Disclaimer
Please note that web scraping may have legal implications, and it is essential to ensure compliance with the website's terms of service and data usage policy. Respect the website's server load and bandwidth, and use this tool responsibly.
Data Source
The financial ratios and stock data in this project are scraped from https://www.screener.in/. Please review their terms of service and data usage policy for more information on data access and usage.
Requirements
- Python 3.x
requestslibraryBeautifulSouplibrarytqdmlibrary
How to Use
The code is divided into two classes: FetchStocks and FetchStocksData.
-
Import library or Clone it.
- To Import STEP-1:
pip install stockscraper - To Import STEP-2
Create a .py file and write
import stockscraperIn any case, above code don't work use,from stockscraper import *
- To Import STEP-1:
-
Creating an Object to Get Names and corresponding links of stocks
Do the above step only for firsttime
obj_1 = stockscraper.fetchStocks(stockname,stinfo)No need to run the above line again, as long as you see a StockLink.txt in your folder.
once you get all the name and corresponding links of stocks, create a new object of class FetchStockData
It takes two arrays as an argument to store stock name and stockinfoobj_2 = stockscraper.fetchStockData(stinfo)
This will get data of each stock and store them in a comman array. It takes one array as an argument.stockscraper.fetchStockData.getRatios()
It takes 8 array's as argument, to sort and store each data seperately obtained from above line individually.
The array arg's should be in order- MarketCap,
- CurrentPrice,
- StockPE,
- BookValue,
- DividendYield,
- ROCE,
- ROE,
- FaceValue.
stockscraper.fetchStockData.exportRatios()
It Stores all the Ratios obtained earlier in a .txt file for furthur usage
It takes 8 arrays as an argument in order MarketCap,CurrentPrice,StockPE,BookValue,DividendYield,ROCE,ROE,FaceValue.
License
MIT License
Copyright (c) 2023 Pallav
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Release files for stockscraper 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stockscraper-0.1.1.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stockscraper-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:11.5 kB
Release files / stockscraper-0.1.1.tar.gz
| Download URL | stockscraper-0.1.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ec40bf04c056d052eb8295d4e161d8ef386ab4d943badfc361b1843480f349b
|
|
BLAKE2b-256 checksum How to use checksums |
e737eeaf58b7751e6dc9f520cc4c0f3e298e4e162785eb240904b11f3a5dfef0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / stockscraper-0.1.1-py3-none-any.whl
| Download URL | stockscraper-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6796a814de2c5628b1afc79a551baa5df32daf8b944962f82b4fe8419adf96a7
|
|
BLAKE2b-256 checksum How to use checksums |
716410344cb4add14aa5d450ab831b99a776744d1ad12629b69e7a4642b4a14b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|