Something nested
15 | 16 | 17 |Something nested 2
18 | 19 | 20 |├── release.sh ├── .github ├── FUNDING.yml └── workflows │ └── build.yml ├── docs ├── source │ ├── modules.rst │ └── activesoup.rst ├── netlify.toml ├── support.rst ├── _templates │ └── layout.html ├── install.rst ├── index.rst ├── Makefile ├── make.bat ├── conf.py ├── requirements.txt └── gettingstarted.rst ├── src ├── activesoup │ ├── __init__.py │ ├── response.py │ ├── driver.py │ └── html.py └── conftest.py ├── tests ├── test_files │ ├── simple_page.html │ ├── page_with_comments.html │ ├── page_with_form.html │ ├── page_with_nested_objects.html │ ├── page_with_article_list.html │ ├── page_with_checkboxes_and_radios.html │ └── page_with_form_no_method.html ├── test_json_decode.py ├── test_csv.py ├── test_gets.py ├── test_xpath_finds.py ├── test_forms.py └── conftest.py ├── .bumpversion.cfg ├── .travis.yml ├── .pre-commit-config.yaml ├── make-docs.sh ├── LICENSE ├── pyproject.toml ├── CONTRIBUTING.md ├── .gitignore ├── README.rst └── poetry.lock /release.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -euo pipefail 3 | poetry run bump2version "$@" 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [jelford] 4 | -------------------------------------------------------------------------------- /docs/source/modules.rst: -------------------------------------------------------------------------------- 1 | activesoup 2 | ========== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | activesoup 8 | -------------------------------------------------------------------------------- /docs/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "_build/html" 3 | command = "make html" 4 | 5 | [build.environment] 6 | RUBY_VERSION = "2.7.2" 7 | PYTHON_VERSION = "3.8" 8 | -------------------------------------------------------------------------------- /src/activesoup/__init__.py: -------------------------------------------------------------------------------- 1 | from .response import Response 2 | from .driver import Driver 3 | 4 | __all__ = ["Response", "Driver"] 5 | 6 | __version__ = "0.3.1" 7 | -------------------------------------------------------------------------------- /tests/test_files/simple_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |text-in-body
12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/test_json_decode.py: -------------------------------------------------------------------------------- 1 | from activesoup import driver 2 | 3 | 4 | def test_json_response_decoded_as_json_object(localwebserver): 5 | d = driver.Driver() 6 | resp = d.get(f"http://localhost:{localwebserver.port}/json?foo=bar") 7 | assert resp["foo"] == "bar" 8 | -------------------------------------------------------------------------------- /docs/support.rst: -------------------------------------------------------------------------------- 1 | Support 2 | ------- 3 | 4 | The best way to get support is to file an issue on the main `GitHub project`_. This 5 | is a part-time hobby project, so please be patient as it might take a few days for 6 | someone to get to your issue. 7 | 8 | .. _GitHub project: https://github.com/jelford/activesoup/issues 9 | 10 | -------------------------------------------------------------------------------- /tests/test_files/page_with_comments.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compatibility shim 6 | 7 | 8 |some body text
9 | 10 | 11 | -------------------------------------------------------------------------------- /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.3.1 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:pyproject.toml] 7 | search = version = "{current_version}" 8 | replace = version = "{new_version}" 9 | 10 | [bumpversion:file:src/activesoup/__init__.py] 11 | search = __version__ = "{current_version}" 12 | replace = __version__ = "{new_version}" 13 | -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends '!layout.html' %} 2 | 3 | {% block footer %} 4 | 5 | 7 | 10 | {% endblock %} -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | install: 5 | - pip install tox flake8 6 | script: 7 | - flake8 src tests 8 | - tox 9 | 10 | before_deploy: "pip install wheel --upgrade" 11 | deploy: 12 | provider: pypi 13 | user: "jelford" 14 | password: ${PYPI_PASSWORD} 15 | distributions: "sdist bdist_wheel" 16 | on: 17 | tags: true 18 | branch: master 19 | -------------------------------------------------------------------------------- /docs/install.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ------------ 3 | 4 | At the command line: 5 | 6 | .. code-block:: 7 | 8 | pip install activesoup 9 | 10 | 11 | Or, if you are using a tool like `poetry`_ or `pipenv`_: 12 | 13 | .. code-block:: 14 | 15 | poetry add activesoup 16 | pipenv install activesoup 17 | 18 | .. _poetry: https://python-poetry.org/ 19 | .. _pipenv: https://pipenv.pypa.io/en/latest/ 20 | 21 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v2.3.0 4 | hooks: 5 | - id: check-yaml 6 | - id: end-of-file-fixer 7 | - id: trailing-whitespace 8 | - repo: https://github.com/psf/black 9 | rev: 20.8b1 10 | hooks: 11 | - id: black 12 | - repo: https://github.com/pre-commit/mirrors-mypy 13 | rev: master 14 | hooks: 15 | - id: mypy 16 | - repo: https://github.com/PyCQA/isort 17 | rev: 5.7.0 18 | hooks: 19 | - id: isort 20 | -------------------------------------------------------------------------------- /make-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\t\n' 4 | 5 | PROJECTROOT=$(git rev-parse --show-toplevel) 6 | DOCSROOT="${PROJECTROOT}/docs" 7 | 8 | poetry export --dev --without-hashes --format requirements.txt > docs/requirements.txt 9 | 10 | cd $DOCSROOT 11 | 12 | make clean 13 | rm -rf "${DOCSROOT}/source" 14 | 15 | export SPHINX_APIDOC_OPTIONS="members,no-undoc-members,show-inheritance" 16 | sphinx-apidoc -o "${DOCSROOT}/source" --ext-intersphinx --module-first "${PROJECTROOT}/src/activesoup" 17 | 18 | make html 19 | -------------------------------------------------------------------------------- /tests/test_csv.py: -------------------------------------------------------------------------------- 1 | from activesoup import Driver 2 | 3 | 4 | def test_can_download_csv(tmp_path, requests_mock): 5 | d = Driver() 6 | output_path = tmp_path / "output.csv" 7 | 8 | requests_mock.get( 9 | "http://remote.test/csv", 10 | headers={"Content-Type": "text/csv"}, 11 | text="Col1,Col2\nVal1,Val2", 12 | ) 13 | 14 | page = d.get("http://remote.test/csv") 15 | page.save(output_path) 16 | 17 | assert output_path.exists() 18 | assert output_path.read_text() == "Col1,Col2\nVal1,Val2" 19 | -------------------------------------------------------------------------------- /tests/test_files/page_with_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |Something nested
15 | 16 | 17 |Something nested 2
18 | 19 | 20 |some body text
9 |