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 Language, 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,
    language=language,
    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.10.tar.gz (974.3 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.10-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.10.tar.gz
  • Upload date:
  • Size: 974.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.10.12 Linux/6.12.10-76061203-generic

File hashes

Hashes for vianu_fraudcrawler-0.2.10.tar.gz
Algorithm Hash digest
SHA256 147cc5b8b469d32b11e5a81880dcac6286fd7af0082f79d8d4cc78d33862f565
MD5 2c53aa5b1b87341c16ed263bb227b235
BLAKE2b-256 06b34dbf9e7dd236ecae3f0dad3924d93f009a8e4818b889cff6f856f22a7898

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vianu_fraudcrawler-0.2.10-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.12.10-76061203-generic

File hashes

Hashes for vianu_fraudcrawler-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d87d1b47b105609b72e1e2e3db910626d513454d82e1eea1aad998c57fab1694
MD5 cf313e999ae610cc67ab32cf4a761055
BLAKE2b-256 6fd46ac71d3c3fd28a885d0534ba1566485ecdf9124fc0fa1f68f129e8247f16

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