Added settings and docs for the generic Web info provider

This commit is contained in:
Jan Böhmer 2026-02-01 17:47:04 +01:00
parent 071f6f8591
commit 722eb7ddab
6 changed files with 86 additions and 5 deletions

View file

@ -96,6 +96,21 @@ The following providers are currently available and shipped with Part-DB:
(All trademarks are property of their respective owners. Part-DB is not affiliated with any of the companies.)
### Generic Web URL Provider
The Generic Web URL Provider can extract part information from any webpage that contains structured data in the form of
[Schema.org](https://schema.org/) format. Many e-commerce websites use this format to provide detailed product information
for search engines and other services. Therefore it allows Part-DB to retrieve rudimentary part information (like name, image and price)
from a wide range of websites without the need for a dedicated API integration.
To use the Generic Web URL Provider, simply enable it in the information provider settings. No additional configuration
is required. Afterwards you can enter any product URL in the search field, and Part-DB will attempt to extract the relevant part information
from the webpage.
Please note that if this provider is enabled, Part-DB will make HTTP requests to external websites to fetch product data, which
may have privacy and security implications.
Following env configuration options are available:
* `PROVIDER_GENERIC_WEB_ENABLED`: Set this to `1` to enable the Generic Web URL Provider (optional, default: `0`)
### Octopart
The Octopart provider uses the [Octopart / Nexar API](https://nexar.com/api) to search for parts and get information.

View file

@ -27,6 +27,7 @@ use App\Exceptions\ProviderIDNotSupportedException;
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
use App\Settings\InfoProviderSystem\GenericWebProviderSettings;
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@ -38,7 +39,7 @@ class GenericWebProvider implements InfoProviderInterface
private readonly HttpClientInterface $httpClient;
public function __construct(HttpClientInterface $httpClient)
public function __construct(HttpClientInterface $httpClient, private readonly GenericWebProviderSettings $settings)
{
$this->httpClient = $httpClient->withOptions(
[
@ -54,9 +55,10 @@ class GenericWebProvider implements InfoProviderInterface
{
return [
'name' => 'Generic Web URL',
'description' => 'Tries to extract a part from a given product',
'description' => 'Tries to extract a part from a given product webpage URL using common metadata standards like JSON-LD and OpenGraph.',
//'url' => 'https://example.com',
'disabled_help' => 'Enable in settings to use this provider'
'disabled_help' => 'Enable in settings to use this provider',
'settings_class' => GenericWebProviderSettings::class,
];
}
@ -67,7 +69,7 @@ class GenericWebProvider implements InfoProviderInterface
public function isActive(): bool
{
return true;
return $this->settings->enabled;
}
public function searchByKeyword(string $keyword): array

View file

@ -0,0 +1,43 @@
<?php
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2026 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace App\Settings\InfoProviderSystem;
use App\Settings\SettingsIcon;
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
use Jbtronics\SettingsBundle\Settings\Settings;
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
use Symfony\Component\Translation\TranslatableMessage as TM;
#[Settings(label: new TM("settings.ips.generic_web_provider"), description: new TM("settings.ips.generic_web_provider.description"))]
#[SettingsIcon("fa-plug")]
class GenericWebProviderSettings
{
use SettingsTrait;
#[SettingsParameter(label: new TM("settings.ips.lcsc.enabled"), description: new TM("settings.ips.generic_web_provider.enabled.help"),
envVar: "bool:PROVIDER_GENERIC_WEB_ENABLED", envVarMode: EnvVarMode::OVERWRITE
)]
public bool $enabled = false;
}

View file

@ -37,6 +37,9 @@ class InfoProviderSettings
#[EmbeddedSettings]
public ?InfoProviderGeneralSettings $general = null;
#[EmbeddedSettings]
public ?GenericWebProviderSettings $genericWebProvider = null;
#[EmbeddedSettings]
public ?DigikeySettings $digikey = null;

View file

@ -10,7 +10,7 @@
{% block card_content %}
<div class="offset-sm-3">
<h3>
{% if info_provider_info.url %}
{% if info_provider_info.url is defined %}
<a href="{{ info_provider_info.url }}" class="link-external" target="_blank" rel="nofollow">{{ info_provider_info.name }}</a>
{% else %}
{{ info_provider_info.name }}

View file

@ -14316,5 +14316,23 @@ Buerklin-API Authentication server:
<target>Only includes attachments in the selected languages in the results.</target>
</segment>
</unit>
<unit id="PNmvQ.U" name="settings.ips.generic_web_provider">
<segment>
<source>settings.ips.generic_web_provider</source>
<target>Generic Web URL Provider</target>
</segment>
</unit>
<unit id="Vk3BoE_" name="settings.ips.generic_web_provider.description">
<segment>
<source>settings.ips.generic_web_provider.description</source>
<target>This info provider allows to retrieve basic part information from many shop page URLs.</target>
</segment>
</unit>
<unit id="Pu8juaH" name="settings.ips.generic_web_provider.enabled.help">
<segment>
<source>settings.ips.generic_web_provider.enabled.help</source>
<target>When the provider is enabled, users can make requests to arbitary websites on behalf of the Part-DB server. Only enable this, if you are aware of the potential consequences.</target>
</segment>
</unit>
</file>
</xliff>