Compare Product Prices Across Walmart and Target

Site walmart.comTask compare-walmart-and-target-pricesVersion v4Updated Sep 28, 2026Category shopping

Search a product on Walmart and Target and extract comparable prices, seller, and shipping or delivery evidence from result cards or a resolved Walmart product page. This skill was captured from a live agent session on walmart.com and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.

Compare current search-result prices for a product across Walmart and Target. The Walmart workflow can also be used alone when the caller wants the first ten product names and prices, a precise price from a resolved Walmart product page, or shipping-inclusive offer evidence from that page.

Use Cases

Use when the caller provides a product name or search phrase and wants prices checked in both stores, wants Walmart-only search results, wants the price of a specific Walmart product, or wants to determine the lowest apparent delivered cost. Treat result cards as candidate offers; distinguish package sizes, quantities, flavors, and marketplace listings from one another. If only a product name is supplied for a precise Walmart item, resolve the opaque product ID from search results before opening the product page.

Automation Flow

  1. Build direct search URLs without visiting either homepage:
  • Target: https://www.target.com/s?searchTerm={query}
  • Walmart: https://www.walmart.com/search?q={query} URL-encode {query}.
  1. For comparison, navigate to the Target URL and run the search-result extractor below on the loaded page, then navigate to the Walmart URL and run it there.
  2. For Walmart-only search requests, navigate directly to the Walmart URL and run the extractor once; return up to the first ten items.
  3. For a precise Walmart product price or shipping-inclusive offer when only a name or search phrase is known, navigate directly to the Walmart search URL, resolve a matching candidate's numeric ID with the product-resolution extractor below, then navigate directly to https://www.walmart.com/ip/{product-id} and run the product-page extractor. Prefer the exact size/model and the official Walmart listing over marketplace duplicates.
  4. If the caller already provides a Walmart numeric product ID or product URL, skip search and navigate directly to that product URL.
  5. For a lowest-delivered-cost conclusion, compare like-for-like package sizes and record the displayed item price together with shipping or delivery charges/evidence. Do not assume that an omitted shipping line means free shipping; report shipping as unknown unless the page explicitly states free, included, or a charge. Location-dependent fulfillment may require the caller's configured address or postal code.
  6. Return the store name, product title or card snippet, every detected price, seller/fulfillment evidence where available, and any uncertainty about shipping or comparability.

Search-result extractor (run with evaluate() on each loaded result page):

(() => {
const host = location.hostname;
const priceRe = /\$\s?\d{1,3}(?:,\d{3})*(?:\.\d{2})?/g;
const clean = s => (s || '').replace(/\s+/g, ' ').trim();
const out = [];
let cards;
if (host.includes('target.com')) {
  cards = [...document.querySelectorAll('[data-test="@web/site-top-of-funnel/ProductCardWrapper"]')];
  cards.forEach(card => {
    const title = card.querySelector('[data-test="product-title"]');
    if (!title) return;
    const text = clean(card.innerText);
    out.push({title: clean(title.innerText), prices: [...new Set(text.match(priceRe) || [])], snippet: text.slice(0, 240)});
  });
} else {
  cards = [...document.querySelectorAll('[data-item-id]')];
  cards.forEach(card => {
    const text = clean(card.innerText);
    if (!text) return;
    const titleNode = card.querySelector('[data-automation-id="product-title"], [data-testid="product-title"], a[aria-label]');
    const title = clean(titleNode?.innerText || titleNode?.getAttribute('aria-label') || '');
    if (!title) return;
    out.push({title, prices: [...new Set(text.match(priceRe) || [])], snippet: text.slice(0, 240)});
  });
}
return JSON.stringify({store: host.includes('target.com') ? 'Target' : 'Walmart', url: location.href, resultCount: cards?.length || 0, items: out.slice(0, 10)});
})()

Walmart product-resolution extractor (run on the loaded Walmart search page):

(() => {
const clean = s => (s || '').replace(/\s+/g, ' ').trim();
const cards = [...document.querySelectorAll('[data-item-id], [data-testid="item-card"], a[href*="/ip/"]')];
const seen = new Set(), items = [];
for (const card of cards) {
  const link = card.matches('a[href*="/ip/"]') ? card : card.querySelector('a[href*="/ip/"]');
  const href = link?.href || '';
  const m = href.match(/\/ip\/[^/?#]+\/(\d+)/);
  if (!m || seen.has(m[1])) continue;
  seen.add(m[1]);
  const titleNode = card.querySelector('[data-automation-id="product-title"], [data-testid="product-title"], [aria-label]');
  const text = clean(card.innerText || link.innerText);
  items.push({id: m[1], url: `https://www.walmart.com/ip/${m[1]}`, title: clean(titleNode?.innerText || titleNode?.getAttribute('aria-label') || link.innerText), snippet: text.slice(0, 300)});
}
return {url: location.href, items: items.slice(0, 20)};
})()

Walmart product-price and shipping extractor (run on the loaded Walmart product page):

(() => {
 const clean = s => (s || '').replace(/\s+/g, ' ').trim();
 const itemprop = document.querySelector('[itemprop="price"]');
 const priceNode = document.querySelector('[data-automation-id="product-price"], [data-testid="price-wrap"]');
 const raw = itemprop?.getAttribute('content') || clean(priceNode?.innerText || itemprop?.textContent);
 const title = clean(document.querySelector('h1')?.innerText || document.title);
 // Scope fulfillment evidence to the product's buy-box/fulfillment region so recommendations and other products do not leak in; fall back to the page only if none is found.
 const scope = document.querySelector('[data-testid="fulfillment-section"],[data-testid="add-to-cart-section"],[data-automation-id="fulfillment-section"],[data-testid="buy-box"],[data-testid="product-fulfillment"]') || document.querySelector('main') || document.body;
 const scoped = !!scope.querySelector && scope !== document.body;
 const body = scope?.innerText || '';
 const lines = [...new Set(body.split(/\r?\n+/).map(clean).filter(Boolean))];
 const fulfillment = lines.filter(x => /shipping|delivery|arrives|free|sold by|shipped by|seller/i.test(x)).slice(0, 30);
 const seller = lines.filter(x => /sold by|shipped by|seller/i.test(x)).slice(0, 10);
 const shipping = lines.filter(x => /shipping|delivery|arrives|free/i.test(x)).slice(0, 20);
 return {url: location.href, title, price: raw || null, priceSource: itemprop ? 'itemprop=price' : priceNode ? 'Walmart price selector' : null, evidenceScoped: scoped, seller, shipping, fulfillment};
})()

Params

  • {query} is URL-encoded in the Walmart q or Target searchTerm parameter.
  • For Walmart-only requests, callers may request either the first ten comparable search cards or a precise resolved product-page price; the latter requires selecting the matching result before navigation.
  • For delivered-cost comparisons, callers may optionally provide {postal-code} or an existing delivery address context so Walmart can render location-specific shipping or delivery charges. If absent, return shipping as unknown when the page does not explicitly state it.

Possible Friction Points

  • Target search uses the searchTerm query parameter and exposes product cards through [data-test="@web/site-top-of-funnel/ProductCardWrapper"]; titles and prices have dedicated data-test selectors.
  • Walmart search uses the q query parameter and commonly marks result cards with [data-item-id]; product-title markup is less consistent, so retain the card snippet and detect prices from card text.
  • Walmart product pages use opaque numeric IDs in /ip/{slug}/{product-id} URLs. Resolve the ID from search results when the caller supplies only a product name; never infer an ID from the product title.
  • Walmart accepts a short numeric product route such as /ip/{product-id} and may normalize it to the canonical slug-and-ID URL when the numeric ID is already known.
  • Product price is commonly exposed through [itemprop="price"] (prefer its content attribute), with [data-automation-id="product-price"] and [data-testid="price-wrap"] as fallbacks.
  • Shipping, delivery, seller, and fulfillment text is often location-dependent and may be rendered dynamically. The product extractor returns matching visible lines as evidence, not as a guarantee that an omitted charge is zero.
  • Search results may mix package sizes, multipacks, sponsored products, and marketplace offers. Do not compare prices without checking the quantity and unit description.
  • Either site may return an empty or bot/consent page instead of results. Report that store as unavailable rather than treating an empty extraction as zero results.
  • Walmart's result-card and title selectors can change; if [data-item-id] cards are absent, report that extraction was unavailable rather than inferring products from unrelated page text.
  • Route browsing through the caller's configured residential proxy and stealth-enabled browser context when required. CAPTCHA solving and proxy setup are execution-environment responsibilities; never treat a challenge or blocked page as product data.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=walmart.com&task=compare-walmart-and-target-prices