This directory lives at /docs/node-scraper-external in the node-scraper repo and contains
an example external plugin package that demonstrates how to create plugins for node-scraper.
External plugins are discovered by node-scraper via Python entry points. This allows plugins to be distributed as separate packages and automatically discovered when installed.
Use the same Python environment as node-scraper.
cd ~/node-scraper
source venv/bin/activate
pip install -e ./docs/node-scraper-externalThis installs ext-nodescraper-plugins in editable mode and registers the plugin entry points.
Check that node-scraper discovered the external plugin:
node-scraper run-plugins -hYou should see SamplePlugin listed alongside built-in plugins.
node-scraper run-plugins SamplePluginPlugins are registered in pyproject.toml using entry points:
[project.entry-points."nodescraper.plugins"]
SamplePlugin = "ext_nodescraper_plugins.sample.sample_plugin:SamplePlugin"When you install the package, Python registers these entry points in the package metadata.
Node-scraper automatically discovers and loads plugins from the nodescraper.plugins entry point group.
/docs/node-scraper-external
├─ pyproject.toml # Package metadata + entry points
└─ ext_nodescraper_plugins/ # Plugin package
└─ sample/ # Plugin module
├─ __init__.py
├─ sample_plugin.py # Plugin class
├─ sample_collector.py # Data collector
├─ sample_analyzer.py # Data analyzer
└─ sample_data.py # Data model
mkdir my-plugin-package
cd my-plugin-package
mkdir -p ext_nodescraper_plugins/my_plugin[project]
name = "my-plugin-package"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["amd-node-scraper"]
[project.entry-points."nodescraper.plugins"]
MyPlugin = "ext_nodescraper_plugins.my_plugin:MyPlugin"
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"Create ext_nodescraper_plugins/my_plugin/__init__.py:
from nodescraper.base import InBandDataPlugin, InBandDataCollector
from pydantic import BaseModel
class MyDataModel(BaseModel):
"""Your data model"""
data: dict
class MyCollector(InBandDataCollector[MyDataModel, None]):
"""Your data collector"""
DATA_MODEL = MyDataModel
def collect_data(self, args=None):
# Collection logic
return MyDataModel(data={})
class MyPlugin(InBandDataPlugin[MyDataModel, None, None]):
"""Your plugin"""
DATA_MODEL = MyDataModel
COLLECTOR = MyCollectorpip install -e .
node-scraper run-plugins -h # Should show MyPlugin
node-scraper run-plugins MyPluginTo add additional plugins to this example package:
- Create a new module under
ext_nodescraper_plugins/ - Register the entry point in
pyproject.toml:[project.entry-points."nodescraper.plugins"] SamplePlugin = "ext_nodescraper_plugins.sample.sample_plugin:SamplePlugin" AnotherPlugin = "ext_nodescraper_plugins.another:AnotherPlugin"
- Reinstall to register the new entry point:
pip install -e . --force-reinstall --no-deps