Saturday, December 28, 2024
Google search engine
HomeLanguagesHow to Install mechanize for Python?

How to Install mechanize for Python?

In this article, we are going to install mechanize for Python. Mechanize was designed by John J. Lee. and Maintenance take over by Kovid Goyal in 2017. It follows the Stateful programmatic web browsing in Python

Features of mechanize module

  • Mechanize browser implements the interface of urllib2.OpenerDirector
  • It has function/methods to HTML form filling
  • Tracking easily Browser history
  • Automatic handling of HTTP-Equiv and Refresh
  • Obtained link parsing
  • urllib2 function exist inside the mechanize

Installation

In Windows

PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI). If PIP is not present, go through How to install PIP on Windows? and follow the instructions provided.

Mechanize can be directly downloaded and installed with the use of pip (package manager). To install mechanize, just go to the command line and type the following command:

pip install mechanize

In Linux

You can install mechanize using pip as well as apt-get command in Linux. To install using pip type the below command in the terminal. 

pip3 install mechanize

To install using the apt type the below command in the terminal.

sudo apt-get install python-mechanize

Installing from Github

To install from github we need to clone the repo into our system. To clone the repo and then install it type the below command in the terminal.

git clone https://github.com/python-mechanize/mechanize.git
cd mechanize
pip3 install -e

Example

mechanize exports the complete interface using mechanize.urlopen() methods.

Python3




# import module
import mechanize
 
# read url with urlopen()
response = mechanize.urlopen("http://www.neveropen.com/")
print(response.read())


 

 

Output:

 

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments