Tuesday, October 7, 2025
HomeLanguagesMagnetic Ink Character Recognition using Python

Magnetic Ink Character Recognition using Python

Magnetic Ink Character Recognition or MICR 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 validate the MICR code and extract information.

Modules needed

  • 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

Approach:

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

Implementation:

Python3




# 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
# MICR code
Micr = "800002012"
  
# url
  
  
# pass the url
# into getdata function
htmldata = getdata(url)
soup = BeautifulSoup(htmldata, 'html.parser')
  
# traverse the bank information
data = []
for i in (soup.find_all("div", class_="text6")):
    data.append((i.get_text()))
  
# Validate the
# data
if len(data) == 0:
    print("Not Valid MICR Code")
else:
    print("Found")
    print(data)


Output:

Found
['MICR Code:- 800002012, STATE BANK OF INDIA, DIGHA']
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32340 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6709 POSTS0 COMMENTS
Nicole Veronica
11874 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6832 POSTS0 COMMENTS
Ted Musemwa
7091 POSTS0 COMMENTS
Thapelo Manthata
6781 POSTS0 COMMENTS
Umr Jansen
6785 POSTS0 COMMENTS