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.4.tar.gz (973.7 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.4-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.4.tar.gz
  • Upload date:
  • Size: 973.7 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.4.tar.gz
Algorithm Hash digest
SHA256 2d88fdc326bf9c2aff20a25e5f2d58f8bc7dd21816328459ff7c02b52a77b14e
MD5 736f25e9f247ce5bb8da42096573ae7d
BLAKE2b-256 abd9dfb065516617d889b76afc7bd6af409acd229fa0f7d335d29089e66d3bc8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d9fec8ed9eb6b58aed0c7e3b0d8e74df4e31961647a6b7915c42a32f6d2808ec
MD5 dc405caf82bcbc1a706dbba873af5842
BLAKE2b-256 43e51fd12d119b045d4abd5ad88a660ad2f8113ed1162ca0a9e75bee2c97072c

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