AI Selector Repair Tool
Pricing
Pay per event
AI Selector Repair Tool
Fix broken CSS and XPath selectors with AI. Provide a URL and broken selectors โ get back updated, working selectors with confidence scores and explanations of what changed in the page structure.
Pricing
Pay per event
Rating
0.0
(0)
Developer
Stas Persiianenko
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
3 days ago
Last modified
Categories
Share
What does AI Selector Repair Tool do?
AI Selector Repair Tool fixes broken CSS and XPath selectors using AI-powered analysis. When a website changes its layout and your scrapers break, this tool takes your broken selectors and the target URL, analyzes the current page structure with an LLM (Claude or GPT), and returns updated working selectors with confidence scores and explanations of what changed.
Instead of manually inspecting HTML diffs and rewriting selectors by hand, let AI handle the tedious work. The tool fetches the current page, sends the HTML and broken selectors to an LLM, and validates that the repaired selectors actually match elements on the page.
Try it now on the Apify platform โ no coding required.
Who is AI Selector Repair Tool for?
๐ง Web Scraping Engineers
- Fix broken scraper selectors without manually inspecting page source
- Integrate into CI/CD pipelines to auto-repair selectors when scrapers fail
- Batch-repair multiple selectors from a single broken scraper
๐ Data Teams
- Keep data pipelines running when source websites update their layouts
- Reduce downtime between website changes and scraper fixes
- Get confidence scores to decide whether to auto-deploy fixes or flag for review
๐ค Automation Builders
- Maintain browser automation scripts (Playwright, Puppeteer, Selenium) when target pages change
- Fix test suite selectors that break after UI updates
- Build self-healing automation workflows
๐ข Scraper-as-a-Service Providers
- Reduce maintenance cost across hundreds of scrapers
- Automate the most common scraper failure mode (selector breakage)
- Pair with Scraper Regression Watchdog for detect-then-fix pipelines
Why use AI Selector Repair Tool?
- ๐ง AI-powered analysis โ uses Claude or GPT to understand what the selector was targeting, not just string matching
- โ Validation built in โ repaired selectors are tested against the actual page HTML before being returned
- ๐ Confidence scores โ each repair includes a 0-1 confidence score so you know when to auto-deploy vs. review manually
- ๐ก Change explanations โ understand WHY your selector broke (class renamed, element restructured, etc.)
- ๐ CSS and XPath โ supports both selector types, with intelligent type detection
- ๐ No login required โ works on any publicly accessible page
- โก HTTP-first โ lightweight HTTP fetching keeps costs low (no browser overhead)
- ๐ API, scheduling, integrations โ run via API, schedule recurring repairs, integrate with 5,000+ apps via Zapier and Make
- ๐ค Pairs with Watchdog โ combine with Scraper Regression Watchdog for automated detect-and-fix workflows
What data can you extract?
AI Selector Repair Tool returns one result per input selector:
| Field | Type | Description |
|---|---|---|
originalSelector | string | The broken selector you provided |
repairedSelector | string | The AI-suggested fix |
selectorType | string | css or xpath |
confidence | number | Confidence score (0-1) |
status | string | repaired, unchanged, or failed |
explanation | string | What changed in the page structure |
matchedElements | number | How many elements the repaired selector matches |
url | string | The page URL that was analyzed |
How much does it cost to repair broken selectors?
AI Selector Repair Tool uses pay-per-event pricing:
| Event | Price |
|---|---|
| Run started | $0.01 per run |
| Selector repaired | $0.003 per selector |
Example costs:
- ๐น Repair 5 selectors: $0.01 + (5 ร $0.003) = $0.025
- ๐น Repair 20 selectors: $0.01 + (20 ร $0.003) = $0.07
- ๐น Repair 100 selectors: $0.01 + (100 ร $0.003) = $0.31
Note: You also pay for the LLM API calls (Anthropic or OpenAI) using your own API key. Claude Sonnet typically costs $0.003-0.01 per selector depending on HTML size.
With Apify's free plan ($5 monthly credits), you can repair approximately 160 selectors per month (Apify costs only, LLM costs separate).
How to repair broken selectors
- Go to AI Selector Repair Tool on Apify
- Enter the URL of the page where your selectors are broken
- Add your broken selectors to the list (CSS or XPath)
- Optionally add descriptions of what each selector targets (improves accuracy)
- Enter your Anthropic or OpenAI API key
- Click Start and wait for results
- Review the repaired selectors, confidence scores, and explanations
- Update your scraper code with the new selectors
Example input for Hacker News:
{"url": "https://news.ycombinator.com","selectors": [".storylink", "td.title > a.storylink"],"selectorDescriptions": ["Story title link", "Story title link (alternative)"],"anthropicApiKey": "sk-ant-..."}
Example input for an e-commerce site:
{"url": "https://example.com/products","selectors": [".product-card .price-tag","div.product-listing span.old-price","//div[@class='product']//span[@class='discount-badge']"],"selectorDescriptions": ["Product price element","Original price (before discount)","Discount badge on product cards"],"anthropicApiKey": "sk-ant-..."}
Input parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | โ | URL of the page where selectors are broken |
selectors | string[] | Yes | โ | List of broken CSS or XPath selectors |
oldHtml | string | No | โ | Old HTML snapshot for better change detection |
selectorDescriptions | string[] | No | โ | What each selector was supposed to target |
anthropicApiKey | string | * | โ | Anthropic API key (provide this OR OpenAI key) |
openaiApiKey | string | * | โ | OpenAI API key (alternative to Anthropic) |
model | string | No | claude-sonnet-4-20250514 | LLM model to use |
maxHtmlLength | number | No | 50000 | Max HTML chars sent to LLM |
proxyConfiguration | object | No | โ | Proxy settings for fetching the page |
*At least one API key (Anthropic or OpenAI) is required.
Output example
[{"originalSelector": ".storylink","repairedSelector": ".titleline > a","selectorType": "css","confidence": 0.95,"status": "repaired","explanation": "Hacker News renamed the 'storylink' class to 'titleline' and wrapped it in a span. The link is now a direct child of '.titleline'.","matchedElements": 30,"url": "https://news.ycombinator.com"},{"originalSelector": "td.title > a.storylink","repairedSelector": "td.title .titleline > a","selectorType": "css","confidence": 0.9,"status": "repaired","explanation": "The 'storylink' class was removed. Links are now inside a '.titleline' span within the title cell.","matchedElements": 30,"url": "https://news.ycombinator.com"}]
Tips for best results
- ๐ Add selector descriptions โ telling the AI "this selects the product price" dramatically improves accuracy vs. just providing the selector string
- ๐ Provide old HTML when possible โ if you have a cached copy of the page when selectors worked, include it via
oldHtmlfor much better change detection - ๐ฏ Start with Claude Sonnet โ it provides the best accuracy. Switch to Haiku or GPT-4o Mini for bulk repairs where speed matters more than precision
- ๐ฐ Reduce
maxHtmlLengthfor simple pages โ if the target elements are near the top of the page, 10,000-20,000 chars is usually enough - โก Batch related selectors โ send all broken selectors for one page in a single run to save on start event costs
- ๐ Check confidence scores โ auto-deploy repairs with confidence โฅ 0.8, manually review anything below
- ๐ Pair with Scraper Regression Watchdog โ detect breakage automatically, then feed broken selectors into this tool
Integrations
- ๐ AI Selector Repair โ Google Sheets โ export repaired selectors to a spreadsheet for team review before deploying fixes
- ๐ Scraper Regression Watchdog โ AI Selector Repair โ Slack โ automated pipeline: detect broken scraper, repair selectors, notify team with results
- ๐ AI Selector Repair โ Make/Zapier โ trigger selector repair when a scraper fails, then auto-update the scraper configuration
- โฐ Scheduled selector health checks โ run weekly on critical scrapers to proactively catch selector drift before it causes failures
- ๐ Webhooks โ get real-time notifications when repairs are complete, trigger downstream scraper updates automatically
Using the Apify API
Node.js
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });const run = await client.actor('automation-lab/ai-selector-repair').call({url: 'https://example.com/products',selectors: ['.product-card .price', '.old-product-name'],selectorDescriptions: ['Product price', 'Product name'],anthropicApiKey: 'sk-ant-...',});const { items } = await client.dataset(run.defaultDatasetId).listItems();console.log(items);
Python
from apify_client import ApifyClientclient = ApifyClient("YOUR_APIFY_TOKEN")run = client.actor("automation-lab/ai-selector-repair").call(run_input={"url": "https://example.com/products","selectors": [".product-card .price", ".old-product-name"],"selectorDescriptions": ["Product price", "Product name"],"anthropicApiKey": "sk-ant-...",})items = client.dataset(run["defaultDatasetId"]).list_items().itemsprint(items)
cURL
curl "https://api.apify.com/v2/acts/automation-lab~ai-selector-repair/runs?token=YOUR_APIFY_TOKEN" \-X POST \-H "Content-Type: application/json" \-d '{"url": "https://example.com/products","selectors": [".product-card .price", ".old-product-name"],"selectorDescriptions": ["Product price", "Product name"],"anthropicApiKey": "sk-ant-..."}'
Use with AI agents via MCP
AI Selector Repair Tool is available as a tool for AI assistants that support the Model Context Protocol (MCP).
Setup for Claude Code
$claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/ai-selector-repair"
Setup for Claude Desktop, Cursor, or VS Code
Add this to your MCP config file:
{"mcpServers": {"apify": {"type": "http","url": "https://mcp.apify.com?tools=automation-lab/ai-selector-repair"}}}
Example prompts
- "My scraper for example.com broke. The selector
.product-list .item-priceno longer works. Can you fix it?" - "Check if these selectors still work on https://news.ycombinator.com:
.storylink,.score" - "I have 10 broken selectors for my e-commerce scraper. Here they are: [...]. Fix them all and tell me which ones you're confident about."
Is it legal to use AI Selector Repair Tool?
AI Selector Repair Tool only reads publicly accessible web pages โ it does not bypass any authentication, CAPTCHA, or access controls. The tool analyzes page structure to help you maintain your web scrapers.
You should always review the Terms of Service of any website you scrape and ensure your usage complies with applicable laws including GDPR and CCPA. For more information, see Apify's guide on ethical web scraping.
FAQ
How accurate are the repaired selectors? Accuracy depends on the complexity of the page change. For simple class renames or element restructuring, accuracy is typically 85-95%. For major page redesigns, accuracy drops โ use the confidence score to gauge reliability. Providing selector descriptions and old HTML significantly improves accuracy.
How much does it cost per repair? Apify charges $0.003 per selector + $0.01 per run. LLM API costs (your own key) add approximately $0.003-0.01 per selector with Claude Sonnet, depending on HTML size. Total cost per selector is typically $0.006-0.013.
Can it fix XPath selectors? Yes. The AI understands both CSS and XPath selectors. However, CSS selector repairs can be validated against the page HTML directly, while XPath repairs rely on the AI's confidence score for validation.
Why are my repaired selectors showing 0 matched elements?
This usually means the page requires JavaScript rendering to display the target elements. Try: (1) providing the rendered HTML via oldHtml, (2) using a proxy if the page is geo-restricted, or (3) checking that the URL is correct and the page is publicly accessible.
Why did the confidence score drop to 0.3? A low confidence score (0.3 or below) means the repaired selector was validated against the page HTML but matched 0 elements. This typically indicates the repair needs manual review โ the AI found a plausible fix but couldn't confirm it works.
Which LLM model should I use? Claude Sonnet 4 (default) offers the best accuracy. Claude Haiku 4.5 is 3-5x cheaper and still good for straightforward repairs. GPT-4o Mini is comparable to Haiku in both cost and quality. Use the best model for critical selectors, cheaper models for bulk operations.
Other scraper tools
- ๐ Scraper Regression Watchdog โ detect when your scrapers break before users notice