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)
Search
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"])
google(), bing(), yahoo() and brave() 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, Yahoo and Brave 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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| webfetch_io-1.2.0.tar.gz | 6.9 kB | Without provenance | Details for webfetch_io-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| webfetch_io-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for webfetch_io-1.2.0-py3-none-any.whl |
Total release size: 14.1 kB
Release files / webfetch_io-1.2.0.tar.gz
| Download URL | webfetch_io-1.2.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c11f1fd723def73e03260a68333cdf1c0ee2c59ec8cb66d20f7e99ac128aaa62
|
|
BLAKE2b-256 checksum How to use checksums |
422328f2fb96398872ad9bfc1fa0c57a45b8e4dba9cffeca625fc1448b904ced
|
| 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.2.0-py3-none-any.whl
| Download URL | webfetch_io-1.2.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf831beb9ff99a2be8a990fb9b41c3ee8fcbe8cc82a4c6f9f117be53a1fc5ba9
|
|
BLAKE2b-256 checksum How to use checksums |
b6db7b792ea11b95987e35892c1168c11b18fd3062c459bb6db765c0cb2556ca
|
| 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.2.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.