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.6.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.6-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 3508416bfb92082e4382e87ceb70b44fc4e0d3beec232945fb12c8df7762e075
MD5 60e519fd1b9d36776e5d6bd189472b50
BLAKE2b-256 7a7e65d3abc70db70ee8df4a79992e39694b5dd03cbe60f55ca94d667cb282a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b88f9cf7630e3b966c6f4b36cb0ae2339a1732cf85cd662dbc323dce75b54787
MD5 05278cf001f45ec5f9c218ecb2df3961
BLAKE2b-256 c940ae374cb78b9fa7947b2638657136ac938654dc1a87ad1f162b29c90cff70

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