MechanicalSoup v0.9.0 Release Notes

Release Date: 2017-11-02 // about 4 years ago
  • Main changes:

    0️⃣ We do not rely on BeautifulSoup's default choice of HTML parser.
    0️⃣ Instead, we now specify lxml as default. As a consequence, the
    0️⃣ default setting requires lxml as a dependency.

    👍 Python 2.6 and 3.3 are no longer supported.

    🚚 The GitHub URL moved from to @moy and
    @hemberger are now officially administrators of the project in
    ➕ addition to @hickford, the original author.

    📚 We now have a documentation site:
    The API is now fully documented, and we have included a tutorial,
    🙋 several more code examples, and a FAQ.

    💻 StatefulBrowser.select_form can now be called without argument,
    0️⃣ and defaults to "form" in this case. It also has a new argument,
    0️⃣ nr (defaults to 0), which can be used to specify the index of
    the form to select if multiple forms match the selection criteria.

    We now use requirement files. You can install the dependencies of
    MechanicalSoup with e.g.::

    ✅ pip install -r requirements.txt -r tests/requirements.txt

    The Form class was restructured and has a new API. The behavior of
    existing code is unchanged, but a new collection of methods has been
    ➕ added for clarity and consistency with the set method:

    • set_input deprecates input
    • set_textarea deprecates textarea
    • set_select is new
    • set_checkbox and set_radio together deprecate check
      0️⃣ (checkboxes are handled differently by default)

    🖨 A new Form.print_summary method allows you to write
    browser.get_current_form().print_summary() to get a summary of the
    fields you need to fill-in (and which ones are already filled-in).

    👍 The Form class now supports selecting multiple options in
    a <select multiple> element.

    🐛 Bug fixes

    💻 Checking checkboxes with browser["name"] = ("val1", "val2") now
    unchecks all checkbox except the ones explicitly specified.

    💻 StatefulBrowser.submit_selected and now
    reset __current_page to None when the result is not an HTML page.
    This fixes a bug where __current_page was still the previous page.

    We don't error out anymore when trying to uncheck a box which
    doesn't have a checkbox attribute.

    Form.new_control now correctly overrides existing elements.

    Internal changes

    ✅ The testsuite has been further improved and reached 100% coverage.

    ✅ Tests are now run against the local version of MechanicalSoup, not
    against the installed version.

    Browser.add_soup will now always attach a soup-attribute.
    If the response is not text/html, then soup is set to None.

    Form.set(force=True) creates an <input type=text ...>
    element instead of an <input type=input ...>.