A simple library for interacting with the web from python
Description
activesoup combines familiar python web capabilities for convenient headless “browsing” functionality:
Modern HTTP support with requests - connection pooling, sessions, …
Convenient access to the web page with an interface inspired by beautifulsoup - convenient HTML navigation.
Robust HTML parsing with html5lib - parse the web like browsers do.
Full documentation can be found at https://activesoup.dev.
Use cases
activesoup aims to provide just enough functionality for basic web automation / crawler tasks. Consider using activesoup when:
You’ve already checked out requests-html
You need to actively interact with some web-page from Python (e.g. submitting forms, downloading files)
You don’t control the site you need to interact with (if you do, just make an API).
You don’t need javascript support (you’ll need selenium or phantomjs).
Usage examples
In the example below, we’ll load a page with a simple form, enumerate the fields, and make a submission:
>>> import activesoup
>>> # Start a session
>>> d = activesoup.Driver()
>>> page = d.get("https://httpbin.org/forms/post")
>>> # conveniently access elements, inspired by BeautifulSoup
>>> form = page.form
>>> # get the power of raw xpath search too
>>> form.find('.//input[@name="size"]')
BoundTag<input>
>>> # any element, searching by attribute
>>> form.find('.//*', name="size")
BoundTag<input>
>>> # or just search by attribute
>>> form.find(name="size")
BoundTag<input>
>>> # inspect element attributes
>>> print([i['name'] for i in form.find_all('input')])
['custname', 'custtel', 'custemail', 'size', 'size', 'size', 'topping', 'topping', 'topping', 'topping', 'delivery']
>>> # work actively with objects on the page
>>> r = form.submit({"custname": "john", "size": "small"})
>>> # responses parsed and ready based on content type
>>> r.keys()
dict_keys(['args', 'data', 'files', 'form', 'headers', 'json', 'origin', 'url'])
>>> r['form']
{'custname': 'john', 'size': 'small', 'topping': 'mushroom'}
>>> # access the underlying requests.Session too
>>> d.session
<requests.sessions.Session object at 0x7f283dc95700>
>>> # log in with cookie support
>>> d.get('https://httpbin.org/cookies/set/foo/bar')
>>> d.session.cookies['foo']
'bar'
Release files for activesoup 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| activesoup-0.3.2.tar.gz | 12.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| activesoup-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.2 kB
Release files / activesoup-0.3.2.tar.gz
| Download URL | activesoup-0.3.2.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2799b21dbddd192f05779ad405d6263617e1a202b1dcda304c7f10d02f71002f
|
|
BLAKE2b-256 checksum How to use checksums |
418e367cbd0395da97fc44cced39c4fd7d5fa5a87eb85a0228262678dfdfafc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / activesoup-0.3.2-py3-none-any.whl
| Download URL | activesoup-0.3.2-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87eafc775f83adbab57782b19a44aa620565b0bd641e4cf5981e6d9cc53e964d
|
|
BLAKE2b-256 checksum How to use checksums |
ff5c0e352eb7fb7f84a8f3e6c1da0430d93950208adb2ea711389d9508407090
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|