Need help with MechanicalSoup?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

3.8K Stars 361 Forks MIT License 591 Commits 31 Opened issues


A Python library for automating interaction with websites.

Services available


Need anything else?

Contributors list

.. image:: /assets/mechanical-soup-logo.png :alt: MechanicalSoup. A Python library for automating website interaction.

Home page


A Python library for automating interaction with websites. MechanicalSoup automatically stores and sends cookies, follows redirects, and can follow links and submit forms. It doesn't do JavaScript.

MechanicalSoup was created by

M Hickford
, who was a fond user of the
library. Unfortunately, Mechanize was
incompatible with Python 3 until 2019
__ and its development stalled for several years. MechanicalSoup provides a similar API, built on Python giants
__ (for HTTP sessions) and
__ (for document navigation). Since 2017 it is a project actively maintained by a small team including
__ and

|Gitter Chat|


|Latest Version| |Supported Versions|

PyPy3 is also supported (and tested against).

Download and install the latest released version from


pip install MechanicalSoup

Download and install the development version from


pip install git+

Installing from source (installs the version in the current working directory)::

python install

(In all cases, add

to the
command to install in the current user's home directory.)


The full documentation is available on You may want to jump directly to the

automatically generated API



__, code to get the results from
a Qwant search:

.. code:: python

"""Example usage of MechanicalSoup to get the results from the Qwant
search engine.

import re import mechanicalsoup import html import urllib.parse

Connect to duckduckgo

browser = mechanicalsoup.StatefulBrowser(user_agent='MechanicalSoup')"")

Fill-in the search form

browser.select_form('#search-form') browser["q"] = "MechanicalSoup" browser.submit_selected()

Display the results

for link in'.result a'): # Qwant shows redirection links, not the actual URL, so extract # the actual URL from the redirect link: href = link.attrs['href'] m = re.match(r"^/redirect/[^/]/(.)$", href) if m: href = urllib.parse.unquote( print(link.text, '->', href)

More examples are available in


For an example with a more complex form (checkboxes, radio buttons and textareas), read



|Build Status| |Coverage Status| |Requirements Status| |Documentation Status| |CII Best Practices| |LGTM Alerts| |LGTM Grade|

Instructions for building, testing and contributing to MechanicalSoup: see


Common problems

Read the


.. |Latest Version| image:: :target: .. |Supported Versions| image:: :target: .. |Build Status| image:: :target: .. |Coverage Status| image:: :target: .. |Requirements Status| image:: :target: .. |Documentation Status| image:: :target: .. |CII Best Practices| image:: :target: .. |Gitter Chat| image:: :target: .. |LGTM Alerts| image:: :target: .. |LGTM Grade| image:: :target:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.