fix: Tighten css selector verification rules

This commit is contained in:
GuppyTheCat
2026-01-25 17:31:51 +03:00
parent afafa37a2e
commit e053fd0eb7
2 changed files with 55 additions and 33 deletions

View File

@@ -3,18 +3,21 @@
To ensure your template works correctly, you must validate that the target page actually contains the data you want to extract.
## 1. Fetch the Page
Use the `WebFetch` tool to retrieve the content of a representative URL provided by the user.
```
Use the `WebFetch` tool or a browser DOM snapshot to retrieve the content of a representative URL provided by the user.
```text
WebFetch(url="https://example.com/recipe/chocolate-cake")
```
## 2. Analyze the Output
### Check for Schema.org (Recommended)
Look for `<script type="application/ld+json">`. This contains structured data which is the most reliable way to extract info.
**Example Found in HTML:**
```html
<script type="application/ld+json">
{
@@ -29,27 +32,34 @@ Look for `<script type="application/ld+json">`. This contains structured data wh
```
**Conclusion:**
* `{{schema:Recipe:name}}` is valid.
* `{{schema:Recipe:author.name}}` is valid.
* **Tip:** You can use `schema:Recipe` in the `triggers` array to automatically select this template for any page with this schema.
- `{{schema:Recipe:name}}` is valid.
- `{{schema:Recipe:author.name}}` is valid.
- **Tip:** You can use `schema:Recipe` in the `triggers` array to automatically select this template for any page with this schema.
### Check for Meta Tags
Look for `<meta>` tags in the `<head>` section.
**Example Found in HTML:**
```html
<meta property="og:title" content="The Best Chocolate Cake" />
<meta name="description" content="A rich, moist chocolate cake recipe." />
```
**Conclusion:**
* `{{meta:og:title}}` is valid.
* `{{meta:description}}` is valid.
### Check for CSS Selectors (Fallback)
- `{{meta:og:title}}` is valid.
- `{{meta:description}}` is valid.
### Check for CSS Selectors (Verified)
If Schema and Meta tags are missing, look for HTML structure (classes and IDs) to use with `{{selector:...}}`.
Selectors must be verified against the fetched HTML or DOM snapshot. Do not guess selectors.
**Example Found in HTML:**
```html
<div class="article-body">
<h1 id="main-title">Chocolate Cake</h1>
@@ -58,10 +68,12 @@ If Schema and Meta tags are missing, look for HTML structure (classes and IDs) t
```
**Conclusion:**
* `{{selector:h1#main-title}}` or `{{selector:h1}}` can extract the title.
* `{{selector:.author-name}}` can extract the author.
- `{{selector:h1#main-title}}` or `{{selector:h1}}` can extract the title.
- `{{selector:.author-name}}` can extract the author.
## 3. Verify Against Base
Compare the available data from your analysis with the properties required by the user's Base (see `references/bases-workflow.md`).
* If the Base requires `ingredients` but the page has no Schema or clear list structure, warn the user that this field might need manual entry or a prompt variable.
- If the Base requires `ingredients` but the page has no Schema or clear list structure, warn the user that this field might need manual entry or a prompt variable.