Skip to main content

Wenbot

Simple bot wrapper of selenium basic functions

Sample code:

import wenbot

bot = wenbot.Bot()
bot.play([
    ('open', 'https://www.google.co.nz/'),
    ('text', 'input[name=q]', 'pip wenbot', 'clear, enter'),
])
input('enter to stop browser')

Optional Proxy Support

Requires browsermob-proxy binary, see https://github.com/lightbody/browsermob-proxy/releases. Requires java to run browsermob-proxy binary. Default browsermob-proxy binary path is set in wenbot.browsermob_proxy_bin. Requires pypi package browsermobproxy, install pip install browsermob-proxy.

Sample Setup

wget https://github.com/lightbody/browsermob-proxy/releases/download/browsermob-proxy-2.1.4/browsermob-proxy-2.1.4-bin.zip
unzip browsermob-proxy-2.1.4-bin.zip
java --version  # make sure java works
pip install browsermob-proxy

Support https Sites

User needs install certification file manually to access https sites properly. See browsermob document here.

Steps in macos:

  • download cert file
wget https://raw.githubusercontent.com/lightbody/browsermob-proxy/master/browsermob-core/src/main/resources/sslSupport/ca-certificate-rsa.cer
  • Open keychain (or this also opens keychan: Chrome menu: Settings > Privacy and security > Security > Manage certificates)
  • Keychain menu: File > Import items > import 'ca-certificate-rsa.cer'
  • It's listed under 'certificates' as 'LittleProxy MITM' but not trusted
  • right click menu > Get info > expand 'Trust' > "When using this certificate" = "Always Trust"
  • Remember delete this item after testing is done.

Sample Code

import json
import pydash
import wenbot

bot = wenbot.Bot(proxy=True)
input('enter to print log and stop browser')
# Chrome window shows up.
# After open webpage and operations
har = bot.proxy.har  # this is a property that pulls data from server
# bot.proxy is a browsermobproxy.client.Client object
# see https://browsermob-proxy-py.readthedocs.io/en/stable/client.html
# har is recorded log
with open('/tmp/har.json', 'wt') as f:
    print(json.dumps(har, indent=4, default=str), file=f)

for entry in pydash.get(har, 'log.entries') or []:
    print(pydash.get(entry, "request.url"))
    print(f'    method={pydash.get(entry, "request.method")}')
    print('    Headers')
    for header in pydash.get(entry, 'request.headers') or []:
        print(f'        {header["name"]}: {header["value"]}')
    print(f'    status={pydash.get(entry, "response.status")}')

Try sample code and open /tmp/har.json see what's HAR structure.

Use bot.proxy.new_har() to record new HAR data.

Default only record headers, not content or binary content (in brosermob-proxy terms).

To specify different options: eg.

bot.proxy.new_har(options={
    'captureHeaders': True,
    'captureContent': True,
    'captureBinaryContent': False,
})

Change History

  • 0.0.9 2021-10-31 update doc for https sites with browsermobproxy and update dependency for bs4
  • 0.0.8 2021-08-19 add sample code
  • 0.0.7 2021-07-14 bugfix
  • 0.0.6 2021-07-14 replace print with log
  • 0.0.5 2021-07-14 Bumps urllib3 from 1.26.4 to 1.26.5

Metadata

Release files for wenbot 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wenbot 0.0.9
File Size Uploaded Provenance Actions
wenbot-0.0.9.tar.gz 7.5 kB Without provenance Details for wenbot-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wenbot 0.0.9
File Interpreter ABI Platform Actions
wenbot-0.0.9-py3-none-any.whl Python 3 none any Details for wenbot-0.0.9-py3-none-any.whl

Total release size: 15.6 kB

Release files / wenbot-0.0.9.tar.gz

Download URL wenbot-0.0.9.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e89939046fdfafb78f8c2650483db52f4d3a33032c2ee2e9df75850861be96ee
BLAKE2b-256 checksum
How to use checksums
5189492a51939578b0fa5ecb063632e67506f2c418aecee099c67d81567aa712
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/57.4.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.12

Release files / wenbot-0.0.9-py3-none-any.whl

Download URL wenbot-0.0.9-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b630b7076b400f5aafdbeb97dd69e0cc0e90890fc4678c013c375d3a0a3fd1d0
BLAKE2b-256 checksum
How to use checksums
aa2384b44f504741a23813ce1d77fffcbfc7e059a041c5afa1eb54b7e582458c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/57.4.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.12

Security for wenbot 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page