Integration: Scrape.do
Fetch any web page as Markdown or HTML through Scrape.do, with proxies, JavaScript rendering and anti-bot handling built in.
Table of Contents
Overview
Scrape.do is a web scraping API. You send it a URL and it returns the page, handling proxies, retries, CAPTCHAs and anti-bot protection for you.
This integration adds a ScrapeDoFetcher component that fetches web pages through Scrape.do and returns them as Haystack Documents. Pages can be returned as Markdown, ready to pass to an LLM, or as raw HTML.
You need a Scrape.do API token. You can get one from Scrape.do. See the Scrape.do documentation for all API parameters.
Installation
pip install scrapedo-haystack
Usage
Components
This integration introduces one component:
ScrapeDoFetcher: takes a list of URLs and returns oneDocumentper page. The page content is incontent, andmetaholdsurl,status_codeandcontent_type.
Main options:
| Option | Default | What it does |
|---|---|---|
output |
"markdown" |
"markdown" or "raw" (original HTML) |
render |
False |
Run JavaScript in a headless browser |
super_proxy |
False |
Use residential and mobile IPs |
geo_code |
None |
Route the request through a country, for example "us" |
extra_params |
None |
Any other Scrape.do parameter, passed as-is |
raise_on_failure |
False |
Raise on a failed URL instead of skipping it |
Fetch pages
import os
from scrapedo_haystack import ScrapeDoFetcher
os.environ["SCRAPEDO_API_KEY"] = "your-token"
fetcher = ScrapeDoFetcher(render=True, geo_code="us")
result = fetcher.run(urls=["https://example.com"])
doc = result["documents"][0]
print(doc.meta["url"])
print(doc.content)
Use in a RAG pipeline
Fetch pages and answer a question from their content:
import os
from haystack import Pipeline
from haystack.components.builders import ChatPromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from scrapedo_haystack import ScrapeDoFetcher
os.environ["SCRAPEDO_API_KEY"] = "your-token"
os.environ["OPENAI_API_KEY"] = "your-openai-key"
template = [
ChatMessage.from_user(
"""Answer the question using only these pages.
{% for doc in documents %}
Source: {{ doc.meta.url }}
{{ doc.content }}
{% endfor %}
Question: {{ question }}"""
)
]
pipe = Pipeline()
pipe.add_component("fetcher", ScrapeDoFetcher(render=True))
pipe.add_component("prompt", ChatPromptBuilder(template=template, required_variables=["question"]))
pipe.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini"))
pipe.connect("fetcher.documents", "prompt.documents")
pipe.connect("prompt.prompt", "llm.messages")
result = pipe.run({
"fetcher": {"urls": ["https://haystack.deepset.ai/overview/intro"]},
"prompt": {"question": "What is Haystack?"},
})
print(result["llm"]["replies"][0].text)
When loading a saved pipeline from YAML, allow this package’s module:
pipe = Pipeline.loads(yaml_text, allowed_modules=["scrapedo_haystack.fetcher"])
License
scrapedo-haystack is distributed under the terms of the
Apache-2.0 license.
