Skip to main content gottem  — one API for every scraper.
Travel
Verified

Trainline Scraper

Extract European train and bus schedules, fare comparisons, and booking options from Trainline travel platform. Built on spider-browser .

Get started Docs
target
thetrainline.com
success rate
99.9%
latency
~4ms
Quick start

Extract data in minutes.

trainline-scraper.ts
import { SpiderBrowser } from "spider-browser";

const spider = new SpiderBrowser({
  apiKey: process.env.SPIDER_API_KEY!,
  stealth: 2,
});

await spider.connect();
const page = spider.page!;
await page.goto("https://www.thetrainline.com/book/results?journeySearchType=single&origin=urn%3Atrainline%3Ageneric%3Aloc%3A5696&destination=urn%3Atrainline%3Ageneric%3Aloc%3A4916&outwardDate=2026-07-01T09%3A00%3A00");
await page.content(12000);

const data = await page.evaluate(`(() => {
  const journeys = [];
  document.querySelectorAll("[data-testid='journey-option']").forEach(el => {
    const departure = el.querySelector("[data-testid='departure-time']")?.textContent?.trim();
    const arrival = el.querySelector("[data-testid='arrival-time']")?.textContent?.trim();
    const duration = el.querySelector("[data-testid='journey-duration']")?.textContent?.trim();
    const price = el.querySelector("[data-testid='journey-price']")?.textContent?.trim();
    const operator = el.querySelector("[data-testid='operator-name']")?.textContent?.trim();
    if (departure) journeys.push({ departure, arrival, duration, price, operator });
  });
  return JSON.stringify({ total: journeys.length, journeys: journeys.slice(0, 10) });
})()`);

console.log(JSON.parse(data));
await spider.close();
ready to run · spider-browser · TypeScript
Fetch API

One endpoint for thetrainline.com.

Structured JSON from thetrainline.com with a single POST. AI-resolved selectors, cached on the first call.

POST /fetch/thetrainline.com/
Departure timeArrival timeDurationPriceOperatorChanges
cURL
curl -X POST https://api.spider.cloud/fetch/thetrainline.com/ \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"return_format": "json"}'
Python
import requests

resp = requests.post(
    "https://api.spider.cloud/fetch/thetrainline.com/",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={"return_format": "json"},
)
print(resp.json())
Node.js
const resp = await fetch("https://api.spider.cloud/fetch/thetrainline.com/", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ return_format: "json" }),
});
const data = await resp.json();
console.log(data);
Extraction

Fields you can pull.

Departure timeArrival timeDurationPriceOperatorChangesRouteFare class
Pricing

Dynamic rate capture

Session-aware scraping captures pricing on thetrainline.com that changes per visitor.

Rendering

Complex SPA handling

Full browser rendering for React/Next.js booking interfaces and search results.

Scale

Destination coverage

Scrape listings across thousands of destinations and date ranges concurrently.

Related

More Travel scrapers.

Start

Start scraping thetrainline.com.

Grab an API key and call the endpoint above. The first request resolves the config; every request after hits cache.