Skip to main content

A data retrieval engine based on Playwright.

Project description

DR Web Engine

DR Web Engine is an open-source data retrieval engine designed for extracting structured data from web pages using Playwright. It allows users to define queries in JSON5 or YAML format and execute them to retrieve data from websites. The project is highly extensible and can be used for web scraping, data extraction, and automation tasks.

Publish to PyPI Build and Push Docker Image Build and Test DR Web Engine


Features

  • Queryable Web: Define data extraction queries in JSON5 or YAML format.
  • Playwright Integration: Leverages Playwright for reliable and efficient web automation.
  • Extensible: Easily extend the engine by adding new parsers, extractors, or custom logic.
  • Command-Line Interface (CLI): Run queries directly from the terminal.
  • Docker Support: Use the engine in a containerized environment for easy deployment.

Installation

Option 1: Install from Source

  1. Clone the repository:
    git clone https://github.com/starlitlog/dr-web-engine.git
    cd dr-web-engine
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Install the project in editable mode:
    pip install -e .
    

Option 2: Install via pip

The project is available on PyPI. You can install it directly via pip:

pip install dr-web-engine

Option 3: Run with Docker

  1. Build the Docker image:
    docker build -t dr-web-engine .
    
  2. Run the container, mounting your local data directory:
    docker run -v $(pwd)/data:/app/data dr-web-engine -q /app/data/query.json5 -o /app/data/output.json
    

Usage

Command Line Interface (CLI)

To execute queries using the CLI, run:

dr-web-engine -q engine/data/query.json5 -o engine/data/output.json

Available Parameters

  • -q or --query: Path to the query file (JSON5 or YAML format).
  • -o or --output: Path to the output file where results will be saved.
  • -f or --format: Query format (json5 or yaml). Default: json5.
  • -l or --log-level: Set the logging level (error, warning, info, debug). Default: error.
  • --log-file: Path to a log file. If not specified, logs are printed to stdout.

Extending the Project

Adding New Parsers

To add a custom parser:

  1. Create a new parser in the web_engine/parsers/ directory.
  2. Implement a parse() function that takes a file path and returns a parsed query.
  3. Register the parser in web_engine/parsers/__init__.py using the get_parser() function.

Example:

# web_engine/parsers/custom_parser.py
def parse(file_path):
    # Custom parsing logic here
    return parsed_query

Adding New Extractors

To add a new extractor:

  1. Create a new extractor in the web_engine/extractors/ directory.
  2. Implement the extraction logic.
  3. Update the execute_query() function in web_engine/engine.py to use the new extractor.

Adding New Query Types

To define a new query type:

  1. Create a new query model in web_engine/models.py.
  2. Modify the ExtractionQuery class to support the new query type.
  3. Add the relevant parsing and extraction logic for the new query type.

Example Queries

JSON5 Query Example

{
  "@url": "https://example.com",
  "@steps": [
    {
      "@xpath": "//div[@class='item']",
      "@name": "items",
      "@fields": {
        "title": ".//h2",
        "description": ".//p"
      }
    }
  ],
  "@pagination": {
    "@xpath": "//a[@class='next']",
    "@limit": 5
  }
}

YAML Query Example

url: https://example.com
steps:
  - xpath: //div[@class='item']
    name: items
    fields:
      title: .//h2
      description: .//p
pagination:
  xpath: //a[@class='next']
  limit: 5

Learn More

For additional details and use cases, check out the blog posts at:

📚 Citation

If you use Dr Web in your research or project, please cite it using the following BibTeX entry:

@misc{prifti2025drwebmodernquerybased,
  title         = {Dr Web: a modern, query-based web data retrieval engine},
  author        = {Ylli Prifti and Alessandro Provetti and Pasquale de Meo},
  year          = {2025},
  eprint        = {2504.05311},
  archivePrefix = {arXiv},
  primaryClass  = {cs.DB},
  url           = {https://arxiv.org/abs/2504.05311},
}

Or check it out on arXiv.


Contributing

Contributions are welcome! To contribute, follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Support

If you encounter any issues or have questions, please open an issue on GitHub.


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

dr_web_engine-0.5.7.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

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

dr_web_engine-0.5.7-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file dr_web_engine-0.5.7.tar.gz.

File metadata

  • Download URL: dr_web_engine-0.5.7.tar.gz
  • Upload date:
  • Size: 51.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for dr_web_engine-0.5.7.tar.gz
Algorithm Hash digest
SHA256 834f671a6c34c0820f9e7bbb5b7be44f95493ea18ba1c9c0b765cc9647fab516
MD5 5b71e17e5774caa8876df7f316b62d4c
BLAKE2b-256 4e17a827509384f226f7edd966fcd8659d810cd248c5659e05013bc8e4972237

See more details on using hashes here.

File details

Details for the file dr_web_engine-0.5.7-py3-none-any.whl.

File metadata

  • Download URL: dr_web_engine-0.5.7-py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for dr_web_engine-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b13bdf2056968d8d1c90de0ea73fce0bf8f8cdfa179ef5ceda56f96e29029b9e
MD5 f8b79abd7210541bb8b8f734a858e976
BLAKE2b-256 82031e123e1742f928531156ee0c1cea94b362476159836d79d1f03595956b4a

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