DEV Community

loading...

Day 93 Of 100DaysOfCode: Bank Data Scrapping

iamdurga profile image Durga Pokharel ・3 min read

This is my 93rd day of #100daysofcode and #python learning journey. For the first project I keep collecting data for this I run my news scrapping code once a day I plan to collect more than 5000 data. I will continue collecting data till 2 weeks from today after that I will do some visualization similarly I also plan to apply some concept of natural language processing to classify news. My first project is not still completed.
Today I also make a plan to scrapped bank data. My aim here is I collect the interest rate of the maximum bank of Nepal and will do some visualization. I still making a plan for it. After I plan will complete I share my whole plan here. Below is my code for the bank's interest rate scrapping using BeautifulSoup and I made DataFrame using pandas.

Bank's Interest rate scrapping code:

Here I import all necessary dependencies.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import re
from bs4 import BeautifulSoup as BS
import requests
import urllib3


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Enter fullscreen mode Exit fullscreen mode

Url of particular bank which contain interest rates.

url = "https://www.muktinathbank.com.np/interest-rates"
Enter fullscreen mode Exit fullscreen mode
http = urllib3.PoolManager()
http.addheaders = [('User-agent', 'Mozilla/61.0')]
web_page = http.request('GET', url)
soup = BS(web_page.data, 'html5lib')
Enter fullscreen mode Exit fullscreen mode
muktinath_intrst = []
table = soup.find("table")
for table in soup.findAll("table"):
  df = pd.read_html(str(table))[0]
  muktinath_intrst.append(df)
Enter fullscreen mode Exit fullscreen mode
muktinath_intrst[0]
Enter fullscreen mode Exit fullscreen mode

Output of above code is,

PRODUCT INFO    PRODUCT INTEREST RATE(PER ANNUM)    PAYMENT ON  MINIMUM BALANCE
0   {{normal-saving-account}}-{{3.50;3.50;NRs. 500...   1. Normal Saving    3.50%   Quarterly Basis Rs. 500
1   {{muktinath-premium-bachat}}-{{3.5;3.5;NRs. 10...   2. Muktinath Premium Bachat 3.50%   Quarterly Basis Rs. 1000
2   NaN 3.Muktinath Special Premium Bachat  3.50%   Quarterly Basis Rs. 2000
3   {{muktinath-super-premium-saving-account}}-{{5...   4. Muktinath Super Premium Bachat   5.50%   Quarterly Basis Rs. 5000
4   NaN 5.Current Account   -   -   Rs. 5000
5   NaN 6.Current Account Other *   -   -   Rs. 1000
6   {{mahila-pewa-bachat-khata}}-{{4.5;4.5;Nrs. 50...   7.Mahila Pewa Bachat    4.50%   Quarterly Basis Rs. 500
7   {{sunaulo-bal-bachat}}-{{3.5;3.5;Nrs. 0;Quater...   8.Sunaulo Bal Shichha Bachat    3.50%   Quarterly Basis -
8   NaN 9. Baidesik Rojgar Bachat   3.50%   Quarterly Basis Rs. 500
9   NaN 10. Micro Personal Saving   3.50%   Quarterly Basis Rs. 100
10  NaN 11. Other Micro Savings 3.50%   Quarterly Basis Rs. 100
11  {{karmachari-bachat}}-{{3.0;3.0;Nrs. 100;Quate...   12. Karmachari Bachat   3.50%   Quarterly Basis -
12  {{sharedhani-bachat-khata}}-{{3.0;3.0;Nrs. 100...   13. Sharedhani Bachat Khata 3.50%   Quarterly Basis Rs. 100
13  NaN 14. Beema Bachat    3.50%   Quarterly Basis Rs. 100
14  NaN 15. Provident Fund Account  3.50%   Quarterly Basis -
15  NaN 16. Samajik Surakchha Bhatta Khata  3.50%   Quarterly Basis -
16  NaN 17. Aatmanirbhar Bachat Khata   5.50%   Quarterly Basis -
17  {{sajilo-bachat-khata}}-{{3.5;3.5;Nrs. 0;Quate...   18. Sajilo Bachat   3.50%   Quarterly Basis -
18  {{mero-pahilo-bachat-khata}}-{{3.5;3.5;Nrs. 0;...   19. Mero Pahilo Bachat Khata    3.50%   Quarterly Basis -
19  NaN 20. Muktinath PMS Khata 3.50%   Quarterly Basis -
20  NaN 21. Muktinath Jeevan Bardan Bachat Khata    4.00%   Monthly Basis   Rs.5000
21  NaN 22.Muktinath Jeevan Bardan Plus Bachat Khata    4.00%   Monthly Basis   Rs.5000
22  NaN 23.Muktinath Jeevan Bardan Premium Bachat Khata 4.00%   Monthly Basis   Rs.5000
23  NaN 24. Byaktigat Upalabdhi Khata   3.50%   Quarterly Basis NaN
24  NaN 25.Sansthagat Upalabdhi Khata   up to 1.75% Quarterly Basis NaN
25  NaN 26. FCY Deposit ($,£,,AUD)  up to 1.50% Quarterly Basis 10
26  NaN 27.Call Depost Account  up to 1.75% Quarterly Basis NaN
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide