Skip to main content

Intelligent Market Monitoring

Project description

fraudcrawler

CI Status Python Version License PyPI

Fraudcrawler is an intelligent market monitoring tool that searches the web for products, extracts product details, and classifies them using LLMs. It combines search APIs, web scraping, and AI to automate product discovery and relevance assessment.

Features

  • Asynchronous pipeline - Products move through search, extraction, and classification stages independently
  • Multiple search engines - Google Search, Google Shopping, and more...
  • Search term enrichment - Automatically find related terms and expand your search
  • Product extraction - Get structured product data via Zyte API
  • LLM classification - Assess product relevance using OpenAI API with custom prompts
  • Marketplace filtering - Focus searches on specific domains
  • Deduplication - Avoid reprocessing previously collected URLs
  • CSV export - Results saved with timestamps for easy tracking

Prerequisites

  • Python 3.11 or higher
  • API keys for:
    • SerpAPI - Google search results
    • Zyte API - Product data extraction
    • OpenAI API - Product classification
    • DataForSEO (optional) - Search term enrichment

Installation

python3.11 -m venv .venv
source .venv/bin/activate
pip install fraudcrawler

Using Poetry:

poetry install

Configuration

Create a .env file with your API credentials (see .env.example for template):

SERPAPI_KEY=your_serpapi_key
ZYTEAPI_KEY=your_zyte_key
OPENAIAPI_KEY=your_openai_key
DATAFORSEO_USER=your_user  # optional
DATAFORSEO_PWD=your_pwd    # optional

Usage

Basic Configuration

For a complete working example, see fraudcrawler/launch_demo_pipeline.py. After setting up the necessary parameters you can launch and analyse the results with:

# Run pipeline
await client.run(
    search_term=search_term,
    search_engines=search_engines,
    language=language,
    location=location,
    deepness=deepness,
    excluded_urls=excluded_urls,
)

# Load results
df = client.load_results()
print(df.head())

Advanced Configuration

Search term enrichment - Find and search related terms:

from fraudcrawler import Enrichment

deepness.enrichment = Enrichment(
    additional_terms=5,
    additional_urls_per_term=10
)

Marketplace filtering - Focus on specific domains:

from fraudcrawler import Host

marketplaces = [
    Host(name="International", domains="zavamed.com,apomeds.com"),
    Host(name="National", domains="netdoktor.ch,nobelpharma.ch"),
]

await client.run(..., marketplaces=marketplaces)

Exclude domains - Exclude specific domains from your results:

excluded_urls = [
    Host(name="Compendium", domains="compendium.ch"),
]

await client.run(..., excluded_urls=excluded_urls)

Skip previously collected URLs:

previously_collected_urls = [
    "https://example.com/product1",
    "https://example.com/product2",
]

await client.run(..., previously_collected_urls=previously_collected_urls)

Website source search - Ingest product listings from configured website templates:

from fraudcrawler import SearchEngineName
from fraudcrawler.scraping.utils import build_website_source_profile

source = build_website_source_profile(
    name="My Shop",
    base_url="https://shop.example/",
    searchable_urls=[
        {
            "filterUrl": "search?q={search_term}",
            "includeSubstrings": ["/p/"],
            "excludeSubstrings": [],
        }
    ],
    render_options={
        "javascript": True,
        "includeIframes": False,
        "actions": [],
        "networkCapture": [],
    },
)

await client.run(
    ...,
    search_engines=[SearchEngineName.WEBSITE_SOURCE],
    website_source_sources=[source],
)

Notes:

  • Website-source jobs run for the initial search term only (enrichment terms are not used for website-source ingestion).
  • URL results still pass the regular country-code filtering used by the scraping pipeline.

Redis cache – Set REDIS_USE_CACHE=true and run Redis to cache API and scrape calls (Searcher, Enricher, Zyte, Workflow).

View all results from a client instance:

client.print_available_results()

Output

Results are saved as CSV files in data/results/ with the naming pattern:

<search_term>_<language_code>_<location_code>_<timestamp>.csv

Example: sildenafil_de_ch_20250115143022.csv

The CSV includes product details, URLs, and classification scores from your workflows. Raw page HTML is intentionally excluded from CSV exports to keep result files smaller.

Development

For detailed contribution guidelines, see CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Architecture

Fraudcrawler uses an asynchronous pipeline where products can be at different processing stages simultaneously. Product A might be in classification while Product B is still being scraped. This is enabled by async workers for each stage (Search, Context Extraction, Processing) using httpx.AsyncClient.

Async Setup

For more details on the async design, see the httpx documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fraudcrawler-0.8.10.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fraudcrawler-0.8.10-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file fraudcrawler-0.8.10.tar.gz.

File metadata

  • Download URL: fraudcrawler-0.8.10.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.12 Linux/6.18.15-1.qubes.fc37.x86_64

File hashes

Hashes for fraudcrawler-0.8.10.tar.gz
Algorithm Hash digest
SHA256 ca38e8516fc5580905bb4c2282c972748b0be6016996ee4b6b5d862db9c2bfc3
MD5 cb6dda8b4d941f034b7783b9e6703e36
BLAKE2b-256 f5a0037a3b8d36116b6069d5fa806b6cef61da278d24ea4417243d7ba0c47de8

See more details on using hashes here.

File details

Details for the file fraudcrawler-0.8.10-py3-none-any.whl.

File metadata

  • Download URL: fraudcrawler-0.8.10-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.12 Linux/6.18.15-1.qubes.fc37.x86_64

File hashes

Hashes for fraudcrawler-0.8.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a2a9a2d08b53f9fc294ce490bd3d8e39175b49dc19a4c902dd64e1aba933e8f5
MD5 e684aad3bbee092c1cbb016d8e801aa7
BLAKE2b-256 6050ea456ac19cb3d8e30a6cf39aed115383f3e98b773c665d1caf774ef1c0c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page