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 pipeline

# Execute the pipeline
client.execute(
    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.8.tar.gz (973.9 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.8-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.8.tar.gz
  • Upload date:
  • Size: 973.9 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.8.tar.gz
Algorithm Hash digest
SHA256 0452608cc98dd60175e356314c68bd6b4ff4dacf76d1c0e572590280cf82228b
MD5 01b48a506557e1f854319eea5f116a32
BLAKE2b-256 25de73adc44904127d34ea140090e1bd87f37085371dbe50aaf9d9c6038d3002

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 335d5380f54462fc267e187ed7e9cccbb17fd672be817af374971b285c88bf0c
MD5 b277a09577f74f32f85eef92dfb47b7e
BLAKE2b-256 eb4de702ce39bfec6ea0b19b1e23a4005ff0504d3deb147164dff3672fcd09eb

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