Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Get MICR Code using Python

  • Last Updated : 29 Dec, 2020

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:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

  • bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install this type the below command in the terminal.
pip install bs4
  • requests: Requests allows you to send HTTP/1.1 requests extremely easily. This module also does not comes built-in with Python. To install this type the below command in the terminal.
pip install requests


  • Import module
  • Merge bank information into URL
  • Make requests instance and pass into URL
  • Pass the requests into a Beautifulsoup() function
  • traverse the MICR code into soup object



# 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
state = "BIHAR"
city = "PATNA"
branch = "PATNA"
# url
url = ""+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')):
print("MICR Code :")


MICR Code :

My Personal Notes arrow_drop_up
Recommended Articles
Page :