Library / SDK
MechanicalSoup/MechanicalSoup avatar
MechanicalSoup/MechanicalSoup

MechanicalSoup: Browser Automation Without a Browser, Built on Requests and BeautifulSoup

A Python library for automating interaction with websites. MechanicalSoup provides a similar API, built on Python giants Requests __ (for HTTP sessions) and BeautifulSoup __ (for document navigation).

4,900 stars410 forksPythonMIT

At a glance

What is it?
MechanicalSoup is a Python library that combines Requests and BeautifulSoup to automate form filling, link following, and cookie handling, without executing JavaScript. It suits lightweight scraping tasks but fails on modern interactive sites.
Who is it for?
Adopt MechanicalSoup if your targets are static HTML sites with simple forms and you want a lightweight, MIT-licensed library that builds on Requests and BeautifulSoup. Avoid it if you need JavaScript rendering, complex single-page apps, or headless browser features.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 39 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • MechanicalSoup/MechanicalSoup4,900 ★ · +21
Star history
Repository2026-07-292026-11-14
MechanicalSoup/MechanicalSoup4.9k4.9k

21 Stars in the last 108 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The Problem: Python 3 Automation Without a Browser Engine

The library is not for scraping modern single-page applications. It does not execute JavaScript, so any site that renders content client-side will return empty pages. If your target relies on React, Angular, or similar frameworks, MechanicalSoup will not work. That is a hard boundary, not a limitation you can work around with configuration. The README is explicit: "It doesn't do JavaScript." For developers who need that, a headless browser is the alternative, but for static sites, MechanicalSoup's simplicity is a strength.

How It Works: StatefulBrowser and Form Handling

The form handling goes beyond simple text inputs. The README points to tests/test_browser.py and tests/test_form.py for examples with checkboxes, radio buttons, and textareas. That suggests the library supports a range of form controls, though the documentation does not detail every option. The submit_selected() method presumably handles the form's action and method, including encoding for POST requests. For a developer, this means you can automate multi-step processes like login, search, and data extraction with a few lines of code. The Qwant example shows how to extract results after submission, including parsing redirect URLs with regex and urllib.parse. This is typical of the library's approach: it gives you the tools, but you still write the parsing logic yourself.

Getting Started: Installation and First Script

The example script in the README is a complete, runnable snippet. It imports mechanicalsoup, creates a StatefulBrowser with a custom user_agent, opens a URL, selects a form by CSS selector, sets a field value, submits, and then iterates over result links. This is the entire workflow. There is no need to manage sessions or cookies manually. For a quick test, you could adapt this example to any simple form. The README also mentions that more examples exist in the examples/ directory, and the test files serve as additional documentation for complex forms. If you are evaluating the library, start with a simple form on a site you control, and you will know within minutes whether it fits your needs.

A Genuine Limitation: No JavaScript, No Dynamic Content

The most significant limitation is the lack of JavaScript execution. The README states this directly, but the implications are worth spelling out. Any site that loads content via AJAX, renders data client-side, or uses JavaScript to enable form submission will not work with MechanicalSoup. You will get the initial HTML, but not the content that a browser would generate. Another limitation is that it is not a full browser. It does not handle JavaScript-driven redirects, canvas rendering, or WebSockets. If you need to interact with a site that requires a real browser, you should look at headless browsers like Playwright or Selenium. The README's FAQ might address other common problems, but the JavaScript boundary is the one that matters most for decision-making.

The Alternative: Playwright and the Difference in Approach

The primary alternative for web automation is a headless browser like Playwright. Playwright launches a real Chromium or Firefox instance, executes JavaScript, and provides a high-level API for clicking, typing, and waiting for elements. The difference is fundamental: MechanicalSoup works at the HTTP and HTML level, while Playwright works at the DOM and rendering level. That means Playwright can handle modern sites, but it is heavier. It requires installing a browser binary, consumes more memory, and has a steeper learning curve. MechanicalSoup, by contrast, is a pure Python library with no external dependencies beyond Requests, BeautifulSoup and lxml. If your site is static, MechanicalSoup is faster to write and run. If your site is dynamic, Playwright is the only option among these two. The choice is not about which is better overall, but about which matches your target sites. For a quick script on a legacy form, MechanicalSoup wins on simplicity. For a modern web app, Playwright is necessary.

Maintenance and License: MIT, Active Releases, But Slow Cadence

MechanicalSoup is licensed under MIT, which means you can use it in commercial projects with minimal restrictions. The repository shows an active history with the latest release v1.4.0 from May 2025, following v1.3.0 in July 2023 and v1.2.0 in September 2022. That is roughly one release per year, which is a moderate cadence. The project is not archived, and the README mentions a small team of maintainers since 2017. This suggests the library is stable but not rapidly evolving. For a library this simple, that is acceptable. The risk is that if a dependency like Requests or BeautifulSoup changes its API, the project may lag in updating. However, the library's core functionality is unlikely to change much, so the maintenance cost for your own code is low. You should check the FAQ for any known issues, and monitor the release notes for breaking changes when upgrading. The test suite and CI badges in the README indicate the project is tested.

Editorial conclusion

Adopt MechanicalSoup if your targets are static HTML sites with simple forms and you want a lightweight, MIT-licensed library that builds on Requests and BeautifulSoup. Avoid it if you need JavaScript rendering, complex single-page apps, or headless browser features. Before adopting, verify that your target sites do not rely on client-side rendering or anti-bot measures that require a real browser. Check the FAQ for known issues and test against your specific forms, especially those with checkboxes or radio buttons, as shown in the test files. If JavaScript is unavoidable, consider a headless browser like Playwright instead.

Frequently asked questions

Does MechanicalSoup run JavaScript on the pages it opens?

No. The README says plainly that it doesn't do JavaScript, while it does store and send cookies, follow redirects, follow links and submit forms.

How do I install MechanicalSoup?

Three routes are given: pip install MechanicalSoup for the released version from PyPI, pip install git+https://github.com/MechanicalSoup/MechanicalSoup for the development version, and pip install . for the version in the current directory. Add --user to install into your home directory.

What does MechanicalSoup require as dependencies?

requirements.txt asks for requests >= 2.22.0, beautifulsoup4 >= 4.7 and lxml, plus certifi>=2022.12.7 and urllib3>=2.2.2, which are pinned as indirect dependencies. setup.py sets python_requires to >=3.10, and PyPy3 is supported.

How do I submit a form with MechanicalSoup?

The Qwant example calls browser.select_form('#search-form'), assigns the field with browser["q"] = "MechanicalSoup", then calls browser.submit_selected(). Forms with checkboxes, radio buttons and textareas are covered in tests/test_form.py.

Where is the MechanicalSoup documentation?

The full documentation lives at https://mechanicalsoup.readthedocs.io/, with automatically generated API documentation at mechanicalsoup.readthedocs.io/en/stable/mechanicalsoup.html and a FAQ page for common problems.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mechanicalsoup-mechanicalsoup.svg)](https://hysenlabs.com/projects/mechanicalsoup-mechanicalsoup)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/mechanicalsoup-mechanicalsoup.svg)](https://hysenlabs.com/projects/mechanicalsoup-mechanicalsoup)

Was this useful?