DEV Community

Bugrahan Saka
Bugrahan Saka

Posted on

La Centrale Scraper in Python: French Car Dealers, SIREN/SIRET and Every Car in Stock

La Centrale is one of France's biggest used-car marketplaces, and pros.lacentrale.fr is its dealer directory. Every dealer has a page with its SIREN and SIRET, founding year, a "verified seller" badge, address, opening hours and website, and below that, every car it has for sale: make, model, version, year, mileage, fuel, price, monthly price and La Centrale's own deal rating. The directory lists those dealers by city, department, region and brand. For dealer lead lists, stock monitoring or used-car price research, that is a clean dataset. Here is how to pull it into Python.

Why plain requests fail

import requests

r = requests.get("https://pros.lacentrale.fr/C045088")
print(r.status_code)  # 403
print(r.text[:120])   # ... Please enable JS and disable any ad blocker ...
Enter fullscreen mode Exit fullscreen mode

lacentrale.fr is protected by DataDome, which answers a script with 403 and a JavaScript challenge instead of the page. Sending the request through Scrape.do returns the real server-rendered HTML. A plain request is enough, no extra parameters: 1 credit per page.

import csv
import json
import re
import requests

TOKEN = "<your_token>"


def fetch(url):
    r = requests.get("https://api.scrape.do/", params={"token": TOKEN, "url": url}, timeout=90)
    r.raise_for_status()
    return r.text
Enter fullscreen mode Exit fullscreen mode

Step 1: the dealers of a city

The directory lives on www.lacentrale.fr: /annuaire/garages-villes/<city>, /annuaire/garages-departements/<department>, /annuaire/garages-regions/<region> or /annuaire/marques/<brand>, 20 dealers per page (?page=N&perPage=20). Each card holds the dealer reference, C plus six digits. Read it from data-tracking-meta, not from the link: some dealers link to their own website instead of their La Centrale page.

def dealers(city):
    html = fetch(f"https://www.lacentrale.fr/annuaire/garages-villes/{city}")
    for card in html.split('data-testid="listing-item-container"')[1:]:
        ref = re.search(r"pro_account_ref&quot;:&quot;(C\d+)", card)
        if ref:
            yield ref.group(1)
Enter fullscreen mode Exit fullscreen mode

Lyon has 17 dealers in the directory; Paris has 127, over 7 pages.

Step 2: the dealer page

pros.lacentrale.fr/C045088 carries three things:

  1. An AutoDealer JSON-LD block with the name, address and coordinates. Its openingHoursSpecification is a JSON string inside the JSON, so decode it a second time.
  2. An identity card ("Vendeur vérifié", "Date de création", "Stock") and a footer with SIREN / SIRET and the dealer's website.
  3. window.__PRELOADED_STATE_LISTING__, a JSON object with the first page of stock in search.hits and the stock size in search.total.
def state(html):
    i = html.index("window.__PRELOADED_STATE_LISTING__")
    obj, _ = json.JSONDecoder().raw_decode(html[html.index("{", i):])
    return obj["search"]


def dealer(ref):
    html = fetch(f"https://pros.lacentrale.fr/{ref}")
    ld = json.loads(re.search(r'application/ld\+json[^>]*>(.*?)</script>', html, re.S).group(1))
    hours = json.loads(ld.get("openingHoursSpecification") or "[]")  # a JSON string inside the JSON
    ids = re.search(r"SIREN\D*(\d{9})\D*SIRET\D*(\d{14})", html)
    profile = {"ref": ref, "name": ld["name"], "city": ld["address"]["addressLocality"],
               "siret": ids.group(2) if ids else "", "hours": hours}
    return profile, html
Enter fullscreen mode Exit fullscreen mode

In Lyon all 17 dealers had a SIREN and SIRET, 13 carried the verified badge, and the oldest was founded in 1957.

Step 3: every car in stock

The dealer page doubles as stock page 1, 9 vehicles per page. The next pages are /<ref>/index?options=&page=N&vertical=car, with the same state object:

def stock(ref, first_html):
    search, page = state(first_html), 1
    while True:
        for hit in search["hits"]:
            item, v = hit["item"], hit["item"]["vehicle"]
            yield {"make": v["make"], "model": v["model"], "version": v["version"], "year": v["year"],
                   "mileage": v["mileage"], "energy": v["energy"], "price": item["price"],
                   "deal": item.get("goodDealBadge", ""), "dealer": ref}
        page += 1
        if (page - 1) * search["pageSize"] >= search["total"]:
            break
        search = state(fetch(f"https://pros.lacentrale.fr/{ref}/index?options=&page={page}&vertical=car"))


rows = []
for ref in dealers("lyon"):
    profile, html = dealer(ref)
    rows += list(stock(ref, html))

with open("lyon_cars.csv", "w", newline="", encoding="utf-8") as fh:
    writer = csv.DictWriter(fh, fieldnames=rows[0].keys())
    writer.writeheader()
    writer.writerows(rows)
print(len(rows), "cars")
Enter fullscreen mode Exit fullscreen mode

A live run on Lyon returned 228 cars from 17 dealers for 37 credits. La Centrale rated 42 of them a "very good deal", 52 a "good deal", 68 fairly priced and 12 above market; 47 had no rating. The median asking price was €28,940, and 30 of the 228 were electric.

Limits to know

  • Pages are small: 20 dealers per directory page, 9 cars per stock page. A dealer with 40 cars is 5 requests.
  • Big groups show a national stock on the dealer page ("Stock national : 2468 véhicules"), but the listing only holds the cars at that site.
  • Deal ratings come from La Centrale's market comparison: VERY_GOOD_DEAL, GOOD_DEAL, EQUITABLE_DEAL, BAD_DEAL or NOT_COMPUTED.

Skip the code

The same scraper is an open-source package with a CLI:

pip install lacentrale-pros-scraper
export SCRAPEDO_TOKEN=<your_token>
lacentrale-pros --city lyon --details -o lyon_dealers.json
lacentrale-pros --city lyon --stock -f csv -o lyon_cars.csv
Enter fullscreen mode Exit fullscreen mode

Source and tests: github.com/bugrahansss/lacentrale-pros-scraper

Use the data responsibly

This is business data published by professional sellers, but some dealers are sole traders: treat names and phone numbers as personal data under the GDPR, use them for legitimate purposes, honour objection requests and respect La Centrale's terms. Don't republish vehicle photos.

Run it at scale with Scrape.do

Every page is one plain Scrape.do call: no proxy pool, no DataDome handling, no headless browser. The whole stock of a city like Lyon costs a few dozen credits. Get 1000 free credits and start scraping with Scrape.do.

Top comments (0)