Skip to main content

webfetch-io

Official Python client for the webfetch.io scraping API. Python 3.9+, sync and async, one dependency (httpx).

pip install webfetch-io

Use

from webfetch import WebfetchClient

client = WebfetchClient("wfk_...")          # required; free key at webfetch.io/signup

md = client.markdown("https://example.com")

data = client.extract("https://quotes.toscrape.com/js/", {
    "quotes": {
        "selector": ".quote",
        "type": "list",
        "output": {"text": ".text", "author": ".author"},
    },
})

result = client.fetch("https://example.com", render_js=False, block_ads=True)
print(result.status, result.credits, result.resolved_url)

Async is the same surface, awaited:

from webfetch import AsyncWebfetchClient

async with AsyncWebfetchClient("wfk_...") as client:
    result = await client.fetch("https://example.com", render_js=False)
results = client.bing("python asyncio tutorial", country_code="us")
for r in results["organic_results"]:
    print(r["position"], r["title"], r["url"])

ads = client.search("yahoo", "car insurance quotes", search_type="ads")
print(ads.credits, ads.json()["top_ads"])

bing(), yahoo() and google() return the parsed response; search(engine, query) returns the result object, with credits and json(). The async client has the same methods. Needs a paid plan with the robots.txt opt-out turned on for the key in the key portal: every engine's robots.txt disallows its result pages. Google, Bing and Yahoo are all open. 10 credits a page, 15 with light_request false; a failed search costs nothing. Reference: https://webfetch.io/documentation#search.

Errors

from webfetch import WebfetchApiError, WebfetchRateLimitError

try:
    client.fetch(url)
except WebfetchRateLimitError as e:
    time.sleep(e.retry_after or 5)
except WebfetchApiError as e:
    print(e.status, e.code)      # e.code is stable and safe to branch on

A failed call is never billed.

Credits

render_js defaults to True, which costs 5 credits. Pass render_js=False for a plain HTTP fetch at 1 credit. result.credits reports what was charged.

MIT licensed. Full reference at https://webfetch.io/documentation.

Metadata

Release files for webfetch-io 1.1.1

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

Source distribution (sdist)

Source distribution for webfetch-io 1.1.1
File Size Uploaded Provenance Actions
webfetch_io-1.1.1.tar.gz 6.8 kB Without provenance Details for webfetch_io-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for webfetch-io 1.1.1
File Interpreter ABI Platform Actions
webfetch_io-1.1.1-py3-none-any.whl Python 3 none any Details for webfetch_io-1.1.1-py3-none-any.whl

Total release size: 14.0 kB

Release files / webfetch_io-1.1.1.tar.gz

Download URL webfetch_io-1.1.1.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
166e93cbd91ca4f9c4dfe555ef0203dae640f62af41d6d62c22d1b457da06665
BLAKE2b-256 checksum
How to use checksums
1767f43047d2b50cbc8637a40a9ea31571edbff542786c3d7d8dcd6556caaf28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / webfetch_io-1.1.1-py3-none-any.whl

Download URL webfetch_io-1.1.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa87c02809ef7950d960c94d47802a3a4ac8e32a15ed245120a7bbfef49d7d1a
BLAKE2b-256 checksum
How to use checksums
25567bca97bc7324f0f83cb5b0bb08b22372888a162fb87c08e7bd0d9bbc56a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for webfetch-io 1.1.1

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