Purpose
Find a product matching a supplied query on AliExpress and open the product detail page using its resolved item ID.
When to Use
Use when the caller provides a product name or search query but does not provide an AliExpress item ID or direct product URL.
Workflow
- Build the search URL directly:
https://www.aliexpress.com/w/wholesale-{query}.html, URL-encoding the query and replacing spaces with hyphens as needed. - Navigate to that URL. If AliExpress presents a verification challenge, run the browser's solver once and wait for the page to reload.
- On the loaded search page, resolve a product link without guessing its ID. Select the first visible anchor whose absolute or protocol-relative URL matches
https://www.aliexpress.com/item/{opaque-id}.html; prefer a result whose visible title oraria-labelbest matches{query}. Read its completehref. - Navigate directly to the normalized product URL, preserving the
/item/{id}.htmlpath and omitting tracking query parameters when possible. - Extract the opened product using this self-contained evaluator on the product page:
(() => {
const text = el => (el?.content || el?.textContent || '').replace(/\\s+/g, ' ').trim();
const canonical = document.querySelector('link[rel="canonical"]')?.href || location.href;
const ogTitle = text(document.querySelector('meta[property="og:title"]'));
const title = ogTitle || text(document.querySelector('h1')) || document.title.replace(/\\s*[-|].*$/, '').trim();
const image = text(document.querySelector('meta[property="og:image"]')) || document.querySelector('img')?.src || null;
const price = text(document.querySelector('meta[property="product:price:amount"]')) ||
text(document.querySelector('[class*="price" i]')) || null;
const id = canonical.match(/\\/item\\/(\\d+)\\.html/i)?.[1] ||
location.href.match(/\\/item\\/(\\d+)\\.html/i)?.[1] || null;
return {id, url: canonical, title, price, image};
})()Site-Specific Gotchas
- AliExpress product pages use opaque numeric IDs in URLs shaped like
/item/{id}.html; never fabricate an ID from the product name. - Search result links may be protocol-relative (
//www.aliexpress.com/item/...) and may include extensive tracking parameters such asgps-idandscm; normalize them to HTTPS and retain only the item path when direct navigation is desired. - The homepage is dynamic and may expose misleading generic
div[role="link"]or localizedaria-labelselectors. Prefer the wholesale search URL and anchors whosehrefcontains/item/. - The site can intermittently display an anti-bot verification screen; solve it before inspecting result links and wait for the search results to reappear.
- Product markup and price class names vary by locale and redesign. The evaluator prioritizes stable Open Graph, canonical, and heading metadata, with CSS fallbacks only for missing fields.
Expected Output
An object containing the resolved numeric id, canonical product url, product title, best-effort price, and product image URL. The browser should be left on that product detail page.