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. Bing and Yahoo are open; Google answers 503 engine_unavailable until it opens. 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.0

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.0
File Size Uploaded Provenance Actions
webfetch_io-1.1.0.tar.gz 6.9 kB Without provenance Details for webfetch_io-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 14.1 kB

Release files / webfetch_io-1.1.0.tar.gz

Download URL webfetch_io-1.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
854d721eb9902024b8f698e02222fc6d14fb0c9ea02846576e9624462b784a13
BLAKE2b-256 checksum
How to use checksums
68d437ec6bd8d8006fbbd3fdfda045aee6324e3a61fb41a748763da7734398eb
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.0-py3-none-any.whl

Download URL webfetch_io-1.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e151da82d4a987048ac80b5a562b71a8dee68fd101340d2114df08d7fc545c23
BLAKE2b-256 checksum
How to use checksums
a5e8dfb40b01a16a9c019cc1df8f1272586fc3935aab278429441cdb133b693b
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.0

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