Skip to main content

Intelligent Market Monitoring

Project description

vianu-fraudcrawler

Intelligent Market Monitoring

The pipeline for monitoring the market has the folling main steps:

  1. search for a given term using SerpAPI
  2. get product information using ZyteAPI
  3. assess relevance of the found products using an OpenAI API

Installation

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

Usage

.env file

Make sure to create an .env file with the necessary API keys and credentials (c.f. .env.example file).

Run demo pipeline

python -m fraudcrawler.launch_demo_pipeline

Customize the pipeline

Start by initializing the client

from fraudcrawler import FraudCrawlerClient

# Initialize the client
client = FraudCrawlerClient()

For setting up the search we need 5 main objects

  • search_term: The search term for the query.
  • language: The Language used in SerpAPI ('hl') and for related search terms (within optional enrichement)
  • location: The SerpAPI location ('gl') used for the query.
  • deepness: Defines the search depth.
  • context: The context prompt to use for detecting relevant products
from fraudcrawler import Location, Deepness
# Setup the search
search_term = "sildenafil"
language = Language(name="German")
location = Location(name="Switzerland")
deepness = Deepness(num_results=50)
context = "This organization is interested in medical products and drugs."

(Optional) Add search term enrichement. This will find related search terms (in a given language) and search for these as well.

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

(Optional) Add marketplaces where we explicitely want to look for (this will focus your search as the :site parameter for a google search)

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

(Optional) Exclude urls (where you don't want to find products)

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

And finally run the search

# Run the search
client.run(
    search_term=search_term,
    location=location,
    deepness=deepness,
    context=context,
    # marketplaces=marketplaces,    # Uncomment this for using marketplaces
    # excluded_urls=excluded_urls   # Uncomment this for using excluded_urls
)

This creates a file with name pattern <search_term>_<datetime[%Y%m%d%H%M%S]>.csv inside the folder data/results/.

Once the pipeline terminated the results can be loaded and examined as follows:

df = client.load_results()
print(df.head(n=10))

If the client has been used to run multiple pipelines, an overview of the available results (for a given instance of FraudCrawlerClient) can be obtained with

client.print_available_results()

Contributing

see CONTRIBUTING.md

Async Setup

The following image provides a schematic representation of the package's async setup. Async Setup

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

vianu_fraudcrawler-0.2.5.tar.gz (973.6 kB view details)

Uploaded Source

Built Distribution

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

vianu_fraudcrawler-0.2.5-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file vianu_fraudcrawler-0.2.5.tar.gz.

File metadata

  • Download URL: vianu_fraudcrawler-0.2.5.tar.gz
  • Upload date:
  • Size: 973.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for vianu_fraudcrawler-0.2.5.tar.gz
Algorithm Hash digest
SHA256 8e9dd1b18f409d446d4e7a8d225212daf4bbcbec2c9b5f67f086f378ca04dda6
MD5 b0be093de3a502148eed4bd10673646b
BLAKE2b-256 6b5e4bcc4e72ae1a7e3f596724011a645e23783f98ed2b4f89aa043b07b48074

See more details on using hashes here.

File details

Details for the file vianu_fraudcrawler-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: vianu_fraudcrawler-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for vianu_fraudcrawler-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e4c760e2914a9a1069642b14952b06b894b15cb621ff35b489d571f3a18840bf
MD5 8ff99f4d59e7d4403745ab3487d1a07c
BLAKE2b-256 6cdfe9afb64676b3b771cbd1f51b576c43559a11f2bf0d2c42548fc4a3bad751

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