Files

4.7 KiB

Wikipedia Car Spec Extraction

Extracting vehicle specifications (horsepower, engine, drivetrain) from Wikipedia when web_search/web_extract tools are unavailable.

URL Pattern

Wikipedia car article URLs follow predictable patterns — no search needed:

https://en.wikipedia.org/wiki/{Make}_{Model}
https://en.wikipedia.org/wiki/{Make}_{Model}_(Year)
https://en.wikipedia.org/wiki/{Make}_{Generation_Code}

Known patterns for current-gen hypercars (2024-2026):

  • Ferrari_12Cilindri — 6.5L V12, 819 hp
  • Ferrari_F80 — twin-turbo V6 PHEV, 1,184 hp
  • Ferrari_12Cilindri_Spider — same specs, convertible body
  • Lamborghini_Temerario — twin-turbo V8 PHEV, 907 hp
  • Bugatti_Tourbillon — V16 hybrid PHEV, ~1,800 hp
  • Bugatti_Mistral — quad-turbo W16, 1,600 hp
  • McLaren_W1 — twin-turbo V8 PHEV, 1,258 hp
  • Aston_Martin_Valhalla — twin-turbo V8 PHEV, 1,079 hp
  • Aston_Martin_Vanquish — twin-turbo V12, 824 hp (2025+)
  • Aston_Martin_Vanquish_(2025) — separate page for the new gen
  • Koenigsegg_Gemera — 1,400 hp (3-cyl) / 2,300 hp (V8)
  • Koenigsegg_Jesko — twin-turbo V8, 1,603 hp
  • Koenigsegg_Jesko_Absolut — variant, redirects to main Jesko page
  • Pagani_Utopia — twin-turbo V12, 852 hp / 864 hp
  • Lotus_Emeya — dual-motor EV, 600 hp / 918 hp (R)
  • Porsche_911_(992) — entire 992 generation (use anchors like #992.2)
  • BMW_M5_(G90) — 2025+ M5 (page may be new, watch for missing infobox)
  • Mercedes-AMG_GT_(C192) — second-gen AMG GT
  • Maserati_MC20 — includes MC20 Cielo specs (MC20_Cielo redirects here)

Extraction Technique

Step 1: Download the page

curl -sL --max-time 20 -H "User-Agent: Mozilla/5.0" \
  "https://en.wikipedia.org/wiki/Ferrari_12Cilindri" -o /tmp/car_page.html

Step 2a: Quick HP check via grep

# Find all HP/PS/bhp numbers
grep -oP '\d{3,4}\s*(hp|PS|bhp)' /tmp/car_page.html | head -10

Step 2b: Find infobox and extract power specs

# Find infobox table and grep power-related data
grep -oP 'horsepower.*?(?=</td>)' /tmp/car_page.html
grep -oP '(?:Engine|Power|Layout).*?(?=</td>)' /tmp/car_page.html

Step 2c: Extract full infobox as text

The infobox has class infobox hproduct. Extract it with a Python script to remove HTML:

import re
with open('/tmp/car_page.html') as f:
    html = f.read()
m = re.search(r'<table[^>]*class="infobox[^"]*"[^>]*>.*?</table>', html, re.DOTALL)
if m:
    text = re.sub(r'<[^>]+>', '\n', m.group(0))
    text = re.sub(r'\n+', '\n', text)
    text = re.sub(r'&nbsp;', ' ', text)
    lines = [l.strip() for l in text.split('\n') if l.strip()]
    for l in lines:
        if any(k in l.lower() for k in ['hp', 'ps', 'kw', 'power', 'engine']):
            print(l)

Step 3: Context for specific models

For the Porsche 992 page (single page covers the entire generation), search within:

# Find power specs for specific 992.2 models
grep -oP '.{0,100}541.{0,200}' /tmp/porsche_992_2.html | grep -i 'hp\|ps\|power\|hybrid\|gts'
# 541 PS = 534 hp (992.2 Carrera GTS T-Hybrid)
# 711 PS = 701 hp (992.2 Turbo S)
# 394 PS = 389 hp (992.2 Carrera)

Common Issues

  • Redirect pages (page load returns content from another page) — check <title> tag to confirm
  • Missing infobox — some brand-new pages haven't been fully templated yet (BMW M5 G90 as of Jul 2026)
  • PS vs hp — Wikipedia often shows PS (metric horsepower) first. Convert: 1 PS ≈ 0.986 hp
  • Combined vs individual — Hybrid cars show engine-only + motor-only + combined. Look for "combined" keyword on PHEVs
  • Multiple variants — If a page covers multiple trims (e.g. Emeya 600 hp base / 918 hp R), power may appear multiple times. Verify which trim each spec belongs to

Cross-Reference Against Local Database

When adding to a JSON vehicle database like the portal mockup (/root/portal-mockup/vehicles.json):

  1. Load the existing database — read the full JSON to know what's already covered
  2. Check each found model against the JSON keys (Make → Model → Year)
  3. Apply the new entry only if it's truly missing — don't overwrite existing entries with the same year
  4. Add model year variants — a car launched in 2025 should get entries for at least 2025, possibly 2026 if still in production

The database schema is: { "Make": { "Model": { "Year": HP, ... }, ... }, ... }

Example add:

"Ferrari": {
    ...existing entries...,
    "12Cilindri": {"2025": 819}
}

Sources

Wikipedia infoboxes are sourced from manufacturer press releases and are generally accurate for official HP figures. For track-oriented cars (GT3 RS, GT2 RS, STO, etc.), HP may differ from track-ready numbers if the manufacturer under-rates them — note this uncertainty rather than fabricating.