Haystack integration for ScrapeUnblocker - scrape pages behind anti-bot protections
Project description
scrapeunblocker-haystack
Haystack integration for ScrapeUnblocker - fetch pages that block ordinary HTTP requests.
ScrapeUnblocker renders web pages in a real browser behind anti-bot protections such as Cloudflare, DataDome, PerimeterX and Akamai, so your pipeline gets the real content instead of a block page, a captcha, or an empty JavaScript shell.
Installation
pip install scrapeunblocker-haystack
Setup
Get an API key at scrapeunblocker.com and export it:
export SCRAPEUNBLOCKER_API_KEY=<your-api-key>
Both components read that variable by default, or accept a Secret explicitly.
Components
ScrapeUnblockerFetcher
Fetches URLs and returns one Document per page.
from scrapeunblocker_haystack import ScrapeUnblockerFetcher
fetcher = ScrapeUnblockerFetcher()
result = fetcher.run(urls=["https://example.com"])
print(result["documents"][0].content[:200])
| Parameter | Default | Description |
|---|---|---|
api_key |
SCRAPEUNBLOCKER_API_KEY env var |
ScrapeUnblocker API key |
parsed_data |
False |
Return AI-parsed structured JSON instead of raw HTML |
proxy_country |
None |
Two-letter country code for the exit IP |
time_sleep |
None |
Seconds to wait after load before capturing |
base_url |
https://api.scrapeunblocker.com |
API base URL |
timeout |
180 |
HTTP timeout in seconds |
raise_on_failure |
False |
Raise instead of skipping a URL that fails |
By default a URL that cannot be fetched is logged and skipped, so one bad URL does not discard the rest of the batch.
ScrapeUnblockerWebSearch
Searches Google and returns the organic results as Document objects, with the
snippet as content and title / link / position in the metadata.
from scrapeunblocker_haystack import ScrapeUnblockerWebSearch
search = ScrapeUnblockerWebSearch(top_k=5)
result = search.run(query="best web scraping api")
for doc in result["documents"]:
print(doc.meta["title"], doc.meta["link"])
| Parameter | Default | Description |
|---|---|---|
api_key |
SCRAPEUNBLOCKER_API_KEY env var |
ScrapeUnblocker API key |
pages_to_check |
1 |
How many result pages to scrape |
proxy_country |
None |
Two-letter country code for localised results |
top_k |
None |
Keep at most this many results |
In a pipeline
Search the web, fetch the pages behind the results, and answer from them:
from haystack import Pipeline
from haystack.components.builders import ChatPromptBuilder
from haystack.components.converters import HTMLToDocument
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from scrapeunblocker_haystack import ScrapeUnblockerFetcher
prompt = [
ChatMessage.from_user(
"Answer the question using the pages below.\n\n"
"{% for doc in documents %}{{ doc.content }}\n{% endfor %}\n"
"Question: {{ question }}"
)
]
pipe = Pipeline()
pipe.add_component("fetcher", ScrapeUnblockerFetcher())
pipe.add_component("converter", HTMLToDocument())
pipe.add_component("prompt_builder", ChatPromptBuilder(template=prompt, required_variables="*"))
pipe.add_component("llm", OpenAIChatGenerator())
pipe.connect("fetcher.documents", "converter.sources")
pipe.connect("converter.documents", "prompt_builder.documents")
pipe.connect("prompt_builder.prompt", "llm.messages")
result = pipe.run(
{
"fetcher": {"urls": ["https://example.com"]},
"prompt_builder": {"question": "What is this page about?"},
}
)
print(result["llm"]["replies"][0].text)
Serialization
Both components implement to_dict() / from_dict(), so pipelines using them
can be saved and reloaded. The API key is serialized as a Haystack Secret
reference, not as its value.
Links
- ScrapeUnblocker: https://www.scrapeunblocker.com
- API documentation: https://developers.scrapeunblocker.com
- Haystack: https://haystack.deepset.ai
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapeunblocker_haystack-0.1.0.tar.gz.
File metadata
- Download URL: scrapeunblocker_haystack-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efdbfcb1d63e3cbe6a1a2d60df328fd6d38785f8889319682b41bc5a56960586
|
|
| MD5 |
119a54837a0cccfd2c171b8fd9b404b3
|
|
| BLAKE2b-256 |
28e253d063792c16350eb3fc43585e49415def6ca3634a3b61cb0cdbc456c220
|
Provenance
The following attestation bundles were made for scrapeunblocker_haystack-0.1.0.tar.gz:
Publisher:
publish.yml on ScrapeUnblocker/scrapeunblocker-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scrapeunblocker_haystack-0.1.0.tar.gz -
Subject digest:
efdbfcb1d63e3cbe6a1a2d60df328fd6d38785f8889319682b41bc5a56960586 - Sigstore transparency entry: 2194680399
- Sigstore integration time:
-
Permalink:
ScrapeUnblocker/scrapeunblocker-haystack@7fed5917673d9dce6573cf2b613ea884be8f986f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ScrapeUnblocker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fed5917673d9dce6573cf2b613ea884be8f986f -
Trigger Event:
release
-
Statement type:
File details
Details for the file scrapeunblocker_haystack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scrapeunblocker_haystack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83b4701553ab28552a2f20a904d2d7437761feff5d9a346b9ba35f42b4780af3
|
|
| MD5 |
261ec495d608cc70b7cb42555e5449f6
|
|
| BLAKE2b-256 |
9a28af69f174de3850f2447f12c4e760b771cb8a17b6407968e7d7fdb0984b6a
|
Provenance
The following attestation bundles were made for scrapeunblocker_haystack-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ScrapeUnblocker/scrapeunblocker-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scrapeunblocker_haystack-0.1.0-py3-none-any.whl -
Subject digest:
83b4701553ab28552a2f20a904d2d7437761feff5d9a346b9ba35f42b4780af3 - Sigstore transparency entry: 2194680401
- Sigstore integration time:
-
Permalink:
ScrapeUnblocker/scrapeunblocker-haystack@7fed5917673d9dce6573cf2b613ea884be8f986f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ScrapeUnblocker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fed5917673d9dce6573cf2b613ea884be8f986f -
Trigger Event:
release
-
Statement type: