Documentation
¶
Overview ¶
Package leboncoin isolates leboncoin.fr-specific scraping recipes from ghostchrome's core. It mirrors the layout of packages/linkedin: cobra subtree under `ghostchrome leboncoin <sub>`, URL builders here, parsers in dedicated files, command wiring in cmd.go.
Subcommands:
ghostchrome leboncoin search → keyword/location/category search → CSV
All subcommands reuse ghostchrome's stealth + human-input dynamics + optional cookie injection via `--user-profile leboncoin`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CategoryID = map[string]string{
"voitures": "2",
"motos": "3",
"utilitaires": "4",
"caravaning": "5",
"nautisme": "6",
"immobilier": "8",
"ventes-immo": "9",
"locations": "10",
"colocations": "11",
"informatique": "17",
"telephonie": "18",
"multimedia": "16",
"electromenager": "24",
"meubles": "27",
"electronique": "15",
"jeux-jouets": "31",
"velos": "44",
"emploi": "33",
"services": "34",
"animaux": "29",
"materiel-pro": "32",
}
CategoryID maps short slugs to leboncoin's numeric `category` filter. Values harvested from the public category dropdown. Extend as needed.
var SortToken = map[string]string{
"recent": "time",
"price-asc": "price",
"price-desc": "price",
}
SortToken maps friendly names to leboncoin's `sort` URL parameter.
Functions ¶
func SearchURL ¶
SearchURL builds a leboncoin search URL.
keywords → free text (required) location → city name OR "" for nationwide (e.g. "Paris", "Lyon") category → slug from CategoryID, or raw numeric id, or "" page → 1-indexed sort → "recent", "price-asc", "price-desc", or "" (default = relevance)
Types ¶
type AdRecord ¶
type AdRecord struct {
AdURL string
AdID string
CategorySlug string
Title string
Price string // raw, e.g. "175 €", "2 590 €"
Location string // "Paris 75019 Bassin de la Villette"
Seller string // "professionnel" if pro, "" otherwise
Delivery bool // true if "Livraison possible" present
PriceDrop bool // true if ".. Baisse de prix" annotation present
Category string // human-readable, e.g. "Ordinateurs"
Sponsored bool // true for "Annonce à la une." / "Sponsorisé" pinned slots
}
AdRecord is a row in the search-results CSV output.
func ParseSearchResults ¶
ParseSearchResults walks the rendered text and extracts one AdRecord per `/ad/<slug>/<id>` anchor. The card's metadata sits in the lines that follow the anchor, until either the next anchor or a level change. We use a permissive forward-scan with early stop on the next `@N a>...` line so a malformed card doesn't poison its neighbours.
type CommandFactory ¶
type CommandFactory struct {
BuildBrowserOpts func() engine.BrowserOpts
}
CommandFactory builds the `ghostchrome leboncoin ...` cobra subtree. Same shape as packages/linkedin so callers stay symmetric.
func (*CommandFactory) Register ¶
func (f *CommandFactory) Register(parent *cobra.Command)
Register attaches the leboncoin subcommand tree to the given parent.