././@PaxHeader 0000000 0000000 0000000 00000000034 00000000000 010212 x ustar 00 28 mtime=1688498520.7319238
MechanicalSoup-1.3.0/ 0000755 0001751 0000172 00000000000 14451070531 014006 5 ustar 00runner docker ././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498511.0
MechanicalSoup-1.3.0/LICENSE 0000644 0001751 0000172 00000002052 14451070517 015016 0 ustar 00runner docker The MIT License (MIT)
Copyright (c) 2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498511.0
MechanicalSoup-1.3.0/MANIFEST.in 0000644 0001751 0000172 00000000224 14451070517 015546 0 ustar 00runner docker include LICENSE README.rst
recursive-include tests *.py
include examples/example*.py
include requirements.txt tests/requirements.txt
include docs/*
././@PaxHeader 0000000 0000000 0000000 00000000034 00000000000 010212 x ustar 00 28 mtime=1688498520.7279239
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/ 0000755 0001751 0000172 00000000000 14451070531 020373 5 ustar 00runner docker ././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498520.0
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/PKG-INFO 0000644 0001751 0000172 00000013477 14451070530 021503 0 ustar 00runner docker Metadata-Version: 2.1
Name: MechanicalSoup
Version: 1.3.0
Summary: A Python library for automating interaction with websites
Home-page: https://mechanicalsoup.readthedocs.io/
License: MIT
Project-URL: Source, https://github.com/MechanicalSoup/MechanicalSoup
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6
License-File: LICENSE
.. image:: https://raw.githubusercontent.com/MechanicalSoup/MechanicalSoup/main/assets/mechanical-soup-logo.png
:alt: MechanicalSoup. A Python library for automating website interaction.
Home page
---------
https://mechanicalsoup.readthedocs.io/
Overview
--------
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
`Mechanize `__ 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 `Requests `__ (for
HTTP sessions) and `BeautifulSoup
`__ (for document
navigation). Since 2017 it is a project actively maintained by a small
team including `@hemberger `__ and `@moy
`__.
|Gitter Chat|
Installation
------------
|Latest Version| |Supported Versions|
PyPy3 is also supported (and tested against).
Download and install the latest released version from `PyPI `__::
pip install MechanicalSoup
Download and install the development version from `GitHub `__::
pip install git+https://github.com/MechanicalSoup/MechanicalSoup
Installing from source (installs the version in the current working directory)::
python setup.py install
(In all cases, add ``--user`` to the ``install`` command to
install in the current user's home directory.)
Documentation
-------------
The full documentation is available on
https://mechanicalsoup.readthedocs.io/. You may want to jump directly to
the `automatically generated API
documentation `__.
Example
-------
From `examples/expl_qwant.py `__, 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 Qwant
browser = mechanicalsoup.StatefulBrowser(user_agent='MechanicalSoup')
browser.open("https://lite.qwant.com/")
# Fill-in the search form
browser.select_form('#search-form')
browser["q"] = "MechanicalSoup"
browser.submit_selected()
# Display the results
for link in browser.page.select('.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(m.group(1))
print(link.text, '->', href)
More examples are available in `examples/ `__.
For an example with a more complex form (checkboxes, radio buttons and
textareas), read `tests/test_browser.py `__
and `tests/test_form.py `__.
Development
-----------
|Build Status|
|Coverage Status|
|Documentation Status|
|CII Best Practices|
Instructions for building, testing and contributing to MechanicalSoup:
see `CONTRIBUTING.rst `__.
Common problems
---------------
Read the `FAQ
`__.
.. |Latest Version| image:: https://img.shields.io/pypi/v/MechanicalSoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Supported Versions| image:: https://img.shields.io/pypi/pyversions/mechanicalsoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Build Status| image:: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml/badge.svg?branch=main
:target: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml?query=branch%3Amain
.. |Coverage Status| image:: https://codecov.io/gh/MechanicalSoup/MechanicalSoup/branch/main/graph/badge.svg
:target: https://codecov.io/gh/MechanicalSoup/MechanicalSoup
.. |Documentation Status| image:: https://readthedocs.org/projects/mechanicalsoup/badge/?version=latest
:target: https://mechanicalsoup.readthedocs.io/en/latest/?badge=latest
.. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/1334/badge
:target: https://bestpractices.coreinfrastructure.org/projects/1334
.. |Gitter Chat| image:: https://badges.gitter.im/MechanicalSoup/MechanicalSoup.svg
:target: https://gitter.im/MechanicalSoup/Lobby
././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498520.0
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/SOURCES.txt 0000644 0001751 0000172 00000001432 14451070530 022256 0 ustar 00runner docker LICENSE
MANIFEST.in
README.rst
requirements.txt
setup.cfg
setup.py
MechanicalSoup.egg-info/PKG-INFO
MechanicalSoup.egg-info/SOURCES.txt
MechanicalSoup.egg-info/dependency_links.txt
MechanicalSoup.egg-info/requires.txt
MechanicalSoup.egg-info/top_level.txt
docs/ChangeLog.rst
docs/Makefile
docs/conf.py
docs/external-resources.rst
docs/faq.rst
docs/index.rst
docs/introduction.rst
docs/make.bat
docs/mechanicalsoup.rst
docs/tutorial.rst
examples/example.py
examples/example_manual.py
mechanicalsoup/__init__.py
mechanicalsoup/__version__.py
mechanicalsoup/browser.py
mechanicalsoup/form.py
mechanicalsoup/stateful_browser.py
mechanicalsoup/utils.py
tests/requirements.txt
tests/setpath.py
tests/test_browser.py
tests/test_form.py
tests/test_stateful_browser.py
tests/test_utils.py
tests/utils.py ././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498520.0
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/dependency_links.txt 0000644 0001751 0000172 00000000001 14451070530 024440 0 ustar 00runner docker
././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498520.0
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/requires.txt 0000644 0001751 0000172 00000000052 14451070530 022767 0 ustar 00runner docker requests>=2.22.0
beautifulsoup4>=4.7
lxml
././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498520.0
MechanicalSoup-1.3.0/MechanicalSoup.egg-info/top_level.txt 0000644 0001751 0000172 00000000017 14451070530 023122 0 ustar 00runner docker mechanicalsoup
././@PaxHeader 0000000 0000000 0000000 00000000034 00000000000 010212 x ustar 00 28 mtime=1688498520.7319238
MechanicalSoup-1.3.0/PKG-INFO 0000644 0001751 0000172 00000013477 14451070531 015117 0 ustar 00runner docker Metadata-Version: 2.1
Name: MechanicalSoup
Version: 1.3.0
Summary: A Python library for automating interaction with websites
Home-page: https://mechanicalsoup.readthedocs.io/
License: MIT
Project-URL: Source, https://github.com/MechanicalSoup/MechanicalSoup
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6
License-File: LICENSE
.. image:: https://raw.githubusercontent.com/MechanicalSoup/MechanicalSoup/main/assets/mechanical-soup-logo.png
:alt: MechanicalSoup. A Python library for automating website interaction.
Home page
---------
https://mechanicalsoup.readthedocs.io/
Overview
--------
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
`Mechanize `__ 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 `Requests `__ (for
HTTP sessions) and `BeautifulSoup
`__ (for document
navigation). Since 2017 it is a project actively maintained by a small
team including `@hemberger `__ and `@moy
`__.
|Gitter Chat|
Installation
------------
|Latest Version| |Supported Versions|
PyPy3 is also supported (and tested against).
Download and install the latest released version from `PyPI `__::
pip install MechanicalSoup
Download and install the development version from `GitHub `__::
pip install git+https://github.com/MechanicalSoup/MechanicalSoup
Installing from source (installs the version in the current working directory)::
python setup.py install
(In all cases, add ``--user`` to the ``install`` command to
install in the current user's home directory.)
Documentation
-------------
The full documentation is available on
https://mechanicalsoup.readthedocs.io/. You may want to jump directly to
the `automatically generated API
documentation `__.
Example
-------
From `examples/expl_qwant.py `__, 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 Qwant
browser = mechanicalsoup.StatefulBrowser(user_agent='MechanicalSoup')
browser.open("https://lite.qwant.com/")
# Fill-in the search form
browser.select_form('#search-form')
browser["q"] = "MechanicalSoup"
browser.submit_selected()
# Display the results
for link in browser.page.select('.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(m.group(1))
print(link.text, '->', href)
More examples are available in `examples/ `__.
For an example with a more complex form (checkboxes, radio buttons and
textareas), read `tests/test_browser.py `__
and `tests/test_form.py `__.
Development
-----------
|Build Status|
|Coverage Status|
|Documentation Status|
|CII Best Practices|
Instructions for building, testing and contributing to MechanicalSoup:
see `CONTRIBUTING.rst `__.
Common problems
---------------
Read the `FAQ
`__.
.. |Latest Version| image:: https://img.shields.io/pypi/v/MechanicalSoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Supported Versions| image:: https://img.shields.io/pypi/pyversions/mechanicalsoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Build Status| image:: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml/badge.svg?branch=main
:target: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml?query=branch%3Amain
.. |Coverage Status| image:: https://codecov.io/gh/MechanicalSoup/MechanicalSoup/branch/main/graph/badge.svg
:target: https://codecov.io/gh/MechanicalSoup/MechanicalSoup
.. |Documentation Status| image:: https://readthedocs.org/projects/mechanicalsoup/badge/?version=latest
:target: https://mechanicalsoup.readthedocs.io/en/latest/?badge=latest
.. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/1334/badge
:target: https://bestpractices.coreinfrastructure.org/projects/1334
.. |Gitter Chat| image:: https://badges.gitter.im/MechanicalSoup/MechanicalSoup.svg
:target: https://gitter.im/MechanicalSoup/Lobby
././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498511.0
MechanicalSoup-1.3.0/README.rst 0000644 0001751 0000172 00000011200 14451070517 015473 0 ustar 00runner docker .. image:: /assets/mechanical-soup-logo.png
:alt: MechanicalSoup. A Python library for automating website interaction.
Home page
---------
https://mechanicalsoup.readthedocs.io/
Overview
--------
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
`Mechanize `__ 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 `Requests `__ (for
HTTP sessions) and `BeautifulSoup
`__ (for document
navigation). Since 2017 it is a project actively maintained by a small
team including `@hemberger `__ and `@moy
`__.
|Gitter Chat|
Installation
------------
|Latest Version| |Supported Versions|
PyPy3 is also supported (and tested against).
Download and install the latest released version from `PyPI `__::
pip install MechanicalSoup
Download and install the development version from `GitHub `__::
pip install git+https://github.com/MechanicalSoup/MechanicalSoup
Installing from source (installs the version in the current working directory)::
python setup.py install
(In all cases, add ``--user`` to the ``install`` command to
install in the current user's home directory.)
Documentation
-------------
The full documentation is available on
https://mechanicalsoup.readthedocs.io/. You may want to jump directly to
the `automatically generated API
documentation `__.
Example
-------
From ``__, 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 Qwant
browser = mechanicalsoup.StatefulBrowser(user_agent='MechanicalSoup')
browser.open("https://lite.qwant.com/")
# Fill-in the search form
browser.select_form('#search-form')
browser["q"] = "MechanicalSoup"
browser.submit_selected()
# Display the results
for link in browser.page.select('.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(m.group(1))
print(link.text, '->', href)
More examples are available in ``__.
For an example with a more complex form (checkboxes, radio buttons and
textareas), read ``__
and ``__.
Development
-----------
|Build Status|
|Coverage Status|
|Documentation Status|
|CII Best Practices|
Instructions for building, testing and contributing to MechanicalSoup:
see ``__.
Common problems
---------------
Read the `FAQ
`__.
.. |Latest Version| image:: https://img.shields.io/pypi/v/MechanicalSoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Supported Versions| image:: https://img.shields.io/pypi/pyversions/mechanicalsoup.svg
:target: https://pypi.python.org/pypi/MechanicalSoup/
.. |Build Status| image:: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml/badge.svg?branch=main
:target: https://github.com/MechanicalSoup/MechanicalSoup/actions/workflows/python-package.yml?query=branch%3Amain
.. |Coverage Status| image:: https://codecov.io/gh/MechanicalSoup/MechanicalSoup/branch/main/graph/badge.svg
:target: https://codecov.io/gh/MechanicalSoup/MechanicalSoup
.. |Documentation Status| image:: https://readthedocs.org/projects/mechanicalsoup/badge/?version=latest
:target: https://mechanicalsoup.readthedocs.io/en/latest/?badge=latest
.. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/1334/badge
:target: https://bestpractices.coreinfrastructure.org/projects/1334
.. |Gitter Chat| image:: https://badges.gitter.im/MechanicalSoup/MechanicalSoup.svg
:target: https://gitter.im/MechanicalSoup/Lobby
././@PaxHeader 0000000 0000000 0000000 00000000034 00000000000 010212 x ustar 00 28 mtime=1688498520.7279239
MechanicalSoup-1.3.0/docs/ 0000755 0001751 0000172 00000000000 14451070531 014736 5 ustar 00runner docker ././@PaxHeader 0000000 0000000 0000000 00000000026 00000000000 010213 x ustar 00 22 mtime=1688498511.0
MechanicalSoup-1.3.0/docs/ChangeLog.rst 0000644 0001751 0000172 00000033174 14451070517 017333 0 ustar 00runner docker =============
Release Notes
=============
Version 1.3
===========
Breaking changes
----------------
* To prevent malicious web servers from reading arbitrary files from the
client, files must now be opened explicitly by the user in order to
upload their contents in form submission. For example, instead of:
browser["upload"] = "/path/to/file"
you would now use:
browser["upload"] = open("/path/to/file", "rb")
This remediates
`CVE-2023-34457 `__.
Our thanks to @e-c-d for reporting and helping to fix the vulnerability!
Main changes
------------
* Added support for Python 3.11.
* Allow submitting a form with no submit element. This can be achieved by
passing ``submit=False`` to ``StatefulBrowser.submit_selected``. Thanks
@alexreg!
[`#480 `__]
Bug fixes
---------
* When uploading a file, only the filename is now submitted to the server.
Previously, the full file path was being submitted, which exposed more
local information than users may have been expecting.
[`#375 `__]
Version 1.1
===========
Main changes
------------
* Dropped support for EOL Python versions: 2.7 and 3.5.
* Increased minimum version requirement for requests from 2.0 to 2.22.0
and beautifulsoup4 from 4.4 to 4.7.
* Use encoding from the HTTP request when no HTML encoding is specified.
[`#355 `__]
* Added the ``put`` method to the ``Browser`` class. This is a light wrapper
around ``requests.Session.put``.
[`#359 `__]
* Don't override ``Referer`` headers passed in by the user.
[`#364 `__]
* ``StatefulBrowser`` methods ``follow_link`` and ``download_link``
now support passing a dictionary of keyword arguments to
``requests``, via ``requests_kwargs``. For symmetry, they also
support passing Beautiful Soup args in as ``bs4_kwargs``, although
any excess ``**kwargs`` are sent to Beautiful Soup as well, just as
they were previously.
[`#368 `__]
Version 1.0
===========
This is the last release that will support Python 2.7. Thanks to the many
contributors that made this release possible!
Main changes:
-------------
* Added support for Python 3.8 and 3.9.
* ``StatefulBrowser`` has new properties ``page``, ``form``, and ``url``,
which can be used in place of the methods ``get_current_page``,
``get_current_form`` and ``get_url`` respectively (e.g. the new ``x.page``
is equivalent to ``x.get_current_page()``). These methods may be deprecated
in a future release.
[`#175 `__]
* ``StatefulBrowser.form`` will raise an ``AttributeError`` instead of
returning ``None`` if no form has been selected yet. Note that
``StatefulBrowser.get_current_form()`` still returns ``None`` for
backward compatibility.
Bug fixes
---------
* Decompose ``