Search One-Way Flights on Trip.com

Site trip.comTask search-one-way-flightsVersion v3Updated Sep 17, 2026Category travel

Build Trip.com flight-result URLs for one-way itinerary searches with passenger, cabin, sorting, locale, currency, and optional fare-policy parameters, then extract structured flight options. This skill was captured from a live agent session on trip.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.

Search Trip.com for one-way flights and return the flight-result cards without navigating through the homepage or search form.

Use Cases

Use when the caller provides origin and destination airport codes, departure date, passenger composition, cabin, and optionally sort order, locale, currency, or a specific displayed fare policy.

Automation Flow

  1. Construct the results URL directly, taking the locale domain from the caller and defaulting to trip.com. The observed run used {locale-domain} of jp.trip.com: https://{locale-domain}/flights/showfarefirst?dcity={origin-code}&acity={destination-code}&ddate={YYYY-MM-DD}&class={cabin-code}&triptype=OW&quantity={total-passengers}&childqty={child-passengers-as-trip-classified}&babyqty={infant-passengers}&sort={sort}&locale={locale}&curr={currency}
  2. Optionally append &midpolicyid={url-encoded-policy-id} only when the caller requests a particular displayed fare. Policy IDs observed by Trip.com use the form {variant}:{origin-code}-{destination-code}:{flight-number}; read the exact value from the page or fare-selection state and URL-encode it rather than inventing one.
  3. Navigate to the constructed URL and wait for [data-shoppinginfoid] result cards to render.
  4. In the same browser call, run this extractor on the loaded page:
(() => {
  const clean = s => (s || '').replace(/\s+/g, ' ').trim();
  const cards = [...document.querySelectorAll('[data-shoppinginfoid]')]
    .map(card => {
      const button = card.querySelector('button[data-testid="u_select_btn"]');
      const airlines = [...card.querySelectorAll('[aria-label]')]
        .map(e => clean(e.getAttribute('aria-label')))
        .filter(Boolean);
      const flightNumbers = [...card.querySelectorAll('[data-crawl-flight-no]')]
        .map(e => clean(e.getAttribute('data-crawl-flight-no')))
        .filter(Boolean);
      const flightNames = [...card.querySelectorAll('[data-testid="flights-name"]')]
        .map(e => clean(e.innerText))
        .filter(Boolean);
      return {
        shoppingInfoId: card.getAttribute('data-shoppinginfoid'),
        text: clean(card.innerText),
        airlines: [...new Set(airlines)],
        flightNumbers: [...new Set(flightNumbers)],
        flightNames: [...new Set(flightNames)],
        selectLabel: button ? clean(button.innerText) : null
      };
    })
    .filter(x => x.shoppingInfoId && x.text);
  return { url: location.href, flights: cards };
})()

Possible Friction Points

  • dcity and acity take airport codes, while ddate uses YYYY-MM-DD.
  • quantity is the total traveler count; childqty and babyqty are separate Trip.com passenger-category counts. In the observed flow, a 12-year-old was represented as quantity=3&childqty=0 for two adults plus that traveler, so follow Trip.com's age classification rather than assuming every minor belongs in childqty.
  • class=Y is economy and triptype=OW is one-way. sort=price sorts the result list by price.
  • Result cards expose their opaque fare identifier in data-shoppinginfoid; do not infer or fabricate this identifier. Airline names may appear on descendants with Japanese aria-label values.
  • Flight numbers can be extracted from descendant elements carrying data-crawl-flight-no; displayed carrier/flight labels can also occur under [data-testid="flights-name"].
  • A selected fare detail can append an opaque midpolicyid query parameter to the same results URL. Values follow a pattern such as 1:{origin}-{destination}:{flight-number}, but the complete value must be captured from Trip.com; only add it when a caller specifically requests a particular displayed fare.
  • Results are dynamically rendered, so wait for the cards or [data-shoppinginfoid] elements before extraction.
  • Fare selection may open a modal through button[data-testid="u_select_btn"]; prefer the direct midpolicyid URL when the exact policy identifier is already known, avoiding modal interaction.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=trip.com&task=search-one-way-flights