pax_global_header 0000666 0000000 0000000 00000000064 15016225300 0014504 g ustar 00root root 0000000 0000000 52 comment=a1315f094c1139243c1cc9b1e8a95c1f8c3185e3
MechanicalSoup-1.4.0/ 0000775 0000000 0000000 00000000000 15016225300 0014401 5 ustar 00root root 0000000 0000000 MechanicalSoup-1.4.0/.coveragerc 0000664 0000000 0000000 00000000242 15016225300 0016520 0 ustar 00root root 0000000 0000000 [run]
include =
# The tested code will be located wherever the module was installed.
*/mechanicalsoup/*.py
omit =
*/__version__.py
*/__init__.py
MechanicalSoup-1.4.0/.github/ 0000775 0000000 0000000 00000000000 15016225300 0015741 5 ustar 00root root 0000000 0000000 MechanicalSoup-1.4.0/.github/codecov.yml 0000664 0000000 0000000 00000000065 15016225300 0020107 0 ustar 00root root 0000000 0000000 # Don't post a comment on pull requests
comment: off
MechanicalSoup-1.4.0/.github/dependabot.yml 0000664 0000000 0000000 00000000263 15016225300 0020572 0 ustar 00root root 0000000 0000000 version: 2
updates:
- package-ecosystem: github-actions
# Workflow files stored in the default location of `.github/workflows`
directory: "/"
schedule:
interval: daily
MechanicalSoup-1.4.0/.github/workflows/ 0000775 0000000 0000000 00000000000 15016225300 0017776 5 ustar 00root root 0000000 0000000 MechanicalSoup-1.4.0/.github/workflows/codeql.yml 0000664 0000000 0000000 00000001477 15016225300 0022001 0 ustar 00root root 0000000 0000000 name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "4 7 * * 6"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ python ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
MechanicalSoup-1.4.0/.github/workflows/python-package.yml 0000664 0000000 0000000 00000003045 15016225300 0023435 0 ustar 00root root 0000000 0000000 # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build and Test
# Run workflow for pushes to main and version branches, or pull requests
on:
push:
branches:
- main
- 'v[0-9]+.[0-9]+'
pull_request:
jobs:
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r tests/requirements.txt
- name: Test with pytest without flake8 (for pypy)
if: startsWith(matrix.python-version, 'pypy')
# flake8 runs very slowly with pypy, so skip it (see #146)
run: pytest -o 'flake8-ignore=*.py ALL'
- name: Test with pytest
if: startsWith(matrix.python-version, 'pypy') != true
run: pytest
- name: Generate coverage report
run: coverage xml
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
MechanicalSoup-1.4.0/.github/workflows/python-publish.yml 0000664 0000000 0000000 00000001450 15016225300 0023506 0 ustar 00root root 0000000 0000000 # This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Python Package
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
MechanicalSoup-1.4.0/.gitignore 0000664 0000000 0000000 00000001114 15016225300 0016366 0 ustar 00root root 0000000 0000000 # Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
.eggs
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
.pytest_cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Django stuff:
*.log
*.pot
# Sphinx documentation
docs/_build/
# virtualenv
.virtual-*
MechanicalSoup-1.4.0/.mention-bot 0000664 0000000 0000000 00000000070 15016225300 0016632 0 ustar 00root root 0000000 0000000 {
"userBlacklist": ["moy", "hemberger", "hickford"]
}
MechanicalSoup-1.4.0/.readthedocs.yaml 0000664 0000000 0000000 00000000617 15016225300 0017634 0 ustar 00root root 0000000 0000000 # Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: requirements.txt
MechanicalSoup-1.4.0/CONTRIBUTING.rst 0000664 0000000 0000000 00000010214 15016225300 0017040 0 ustar 00root root 0000000 0000000 Overall Guidelines
------------------
Bug reports, feature suggestions and pull requests welcome (on
GitHub). Security issues should be reported by email to the core
developers (emails available in the "Author" field of commits in the
Git history).
When editing please don't reformat code—this makes diffs and pull
requests hard to read.
Code should be flake8-clean and the test coverage is and should remain
100%. Add new tests whenever you add new features.
Hints on Development
--------------------
|Build Status|
|Coverage Status|
|Documentation Status|
|CII Best Practices|
Python version support in the current main branch may differ from the
latest release in
`PyPI `__. Please inspect our
`GitHub Actions workflows `__
or run ``python setup.py --classifiers`` to see which versions of Python are
supported in the current main branch.
Installing dependencies and running tests can be done with:
::
python setup.py test
The documentation can be generated and viewed with:
::
pip install sphinx
python setup.py build_sphinx
firefox docs/_build/html/index.html
The documentation is generated from docstrings within ``*.py`` files,
and ``*.rst`` documentation files in the ``docs/`` directory.
You can develop against multiple versions of Python using
`virtualenv `__:
::
python3 -m venv .virtual-py3 && source .virtual-py3/bin/activate
pip install -r requirements.txt -r tests/requirements.txt
After making changes, run pytest in all virtualenvs:
::
source .virtual-py3/bin/activate
pytest
Installation should be as simple as:
::
python setup.py install
Editing the logo
----------------
The logo is available as an SVG file in ``assets/``. You may need to
install the `Open Sans
`__ and `Zilla Slab
`__ fonts (download and
store the ``*.ttf`` files in your ``~/.local/share/fonts`` directory)
to view it properly. The file can then be opened in e.g. Inkscape.
Release Checklist
-----------------
Releases can be done only by people with sufficient privileges on
GitHub and PyPI. Things to do are:
At each release:
- Make all final changes to the repository before release:
- Document all notable changes in ``docs/ChangeLog.rst``.
- Update the version number to X.Y.Z in ``mechanicalsoup/__version__.py``.
- Remove the ``(in development)`` mention in ``docs/ChangeLog.rst``.
- Commit and push the release to GitHub (both branch and tag)::
git commit -m "Release X.Y.Z"
git branch vX.Y
git tag vX.Y.Z
git push origin main vX.Y vX.Y.Z
- Visit the `release page on GitHub
`__, copy
the relevant section from ``docs/ChangeLog.rst`` to the release
page.
- Wait for the "Upload Python Package" GitHub Action to complete, and then
check on https://pypi.org/project/MechanicalSoup/. Verify installation
from PyPI with ``pip install --no-cache-dir mechanicalsoup``.
Right after the release:
- Update the version number to a ``X.Y.Z-dev`` number in
``mechanicalsoup/__version__.py``
- Create a new ``(in development)`` section in ``docs/ChangeLog.rst``.
- ``git commit -m "Prepare for next release" && git push``
.. |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
MechanicalSoup-1.4.0/LICENSE 0000664 0000000 0000000 00000002052 15016225300 0015405 0 ustar 00root root 0000000 0000000 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.
MechanicalSoup-1.4.0/MANIFEST.in 0000664 0000000 0000000 00000000224 15016225300 0016135 0 ustar 00root root 0000000 0000000 include LICENSE README.rst
recursive-include tests *.py
include examples/example*.py
include requirements.txt tests/requirements.txt
include docs/*
MechanicalSoup-1.4.0/README.rst 0000664 0000000 0000000 00000011200 15016225300 0016062 0 ustar 00root root 0000000 0000000 .. 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
MechanicalSoup-1.4.0/assets/ 0000775 0000000 0000000 00000000000 15016225300 0015703 5 ustar 00root root 0000000 0000000 MechanicalSoup-1.4.0/assets/mechanical-soup-logo.png 0000664 0000000 0000000 00000307260 15016225300 0022427 0 ustar 00root root 0000000 0000000 PNG
IHDR c' pHYs tIME$J "tEXtFile Name mechanical-soup-logo.png0 8*iTXtXML:com.adobe.xmp
Adobe Photoshop CC 2018 (Macintosh)
2018-08-24T15:00:35-05:00
2018-08-24T15:07:36-05:00
2018-08-24T15:07:36-05:00
image/png
3
xmp.iid:c380d322-c4fb-4d22-995e-f48fecdc9b8e
xmp.did:c380d322-c4fb-4d22-995e-f48fecdc9b8e
xmp.did:c380d322-c4fb-4d22-995e-f48fecdc9b8e
created
xmp.iid:c380d322-c4fb-4d22-995e-f48fecdc9b8e
2018-08-24T15:00:35-05:00
Adobe Photoshop CC 2018 (Macintosh)
1
720000/10000
720000/10000
2
65535
450
436
tEXtSoftware Adobe Photoshop4ˎg tEXtWriter SuperPNGį IDATxy\Gyu^gHfIxm¾CH l&$HB ds$H'@BB c]%Y5eKu^9u푬>#