Open In App

Get MICR Code using Python

MICR stands for Magnetic Ink Character Recognition which is generally used in a bank. This is a 9 digit code to identify the location of the bank branch. MICR code is a code printed on cheques using MICR (Magnetic Ink Character Recognition technology). This enables identification of the cheques and which in turns means faster processing. In this article, we are going to write a python script to Get MICR code using bank information.

Module needed:



pip install bs4
pip install requests

Approach:

Implementation:






# import module
import requests
from bs4 import BeautifulSoup
  
# link for extract html data
# Making a GET request
def getdata(url):
    r = requests.get(url)
    return r.text
  
  
# input by geek
# bank details
bank_name = "KOTAK_MAHINDRA_BANK"
state = "BIHAR"
city = "PATNA"
branch = "PATNA"
  
# url
url = "https://bankifsccode.com/"+bank_name+"/"+state+"/"+city+"/"+branch
  
  
# pass the url
# into getdata function
htmldata = getdata(url)
soup = BeautifulSoup(htmldata, 'html.parser')
  
# traverse the data
data = []
for i in (soup.find_all('a')):
    data.append((i.get_text()))
  
print("MICR Code :")
print(data[17])

Output:

MICR Code :
800485005
Article Tags :