Skip to main content

Unofficial client for Leboncoin API

Project description

lbc

Latest version GitHub license

Unofficial client for Leboncoin API

import lbc

client = lbc.Client()

location = lbc.City( 
    lat=48.85994982004764,
    lng=2.33801967847424,
    radius=10_000, # 10 km
    city="Paris"
)

result = client.search(
    text="maison",
    locations=[location],
    page=1,
    limit=35,
    sort=lbc.Sort.NEWEST,
    ad_type=lbc.AdType.OFFER,
    category=lbc.Category.IMMOBILIER,
    square=[200, 400],
    price=[300_000, 700_000]
)

for ad in result.ads:
    print(ad.url, ad.subject, ad.price)

lbc is not affiliated with, endorsed by, or in any way associated with Leboncoin or its services. Use at your own risk.

Installation

Required Python 3.9+

pip install lbc

Usage

Client

To create client you need to use lbc.Client class

import lbc

client = lbc.Client()

Proxy

You can also configure the client to use a proxy by providing a Proxy object:

proxy = lbc.Proxy(
    host=...,
    port=...,
    username=...,
    password=...
)
client = lbc.Client(proxy=proxy)

Search

To perform a search, use the client.search method.

This function accepts keyword arguments (**kwargs) to customize your query. For example, if you're looking for houses that include both land and parking, you can specify:

real_estate_type=["3", "4"]

These values correspond to what you’d find in a typical Leboncoin URL, like:

https://www.leboncoin.fr/recherche?category=9&text=maison&...&real_estate_type=3,4

Here's a complete example of a search query:

client.search(
    text="maison",
    locations=[location],
    page=1,
    limit=35,
    limit_alu=0,
    sort=lbc.Sort.NEWEST,
    ad_type=lbc.AdType.OFFER,
    category=lbc.Category.IMMOBILIER,
    owner_type=lbc.OwnerType.ALL,
    search_in_title_only=True,
    square=[200, 400],
    price=[300_000, 700_000],
)

Location

The locations parameter accepts a list of one or more location objects. You can use one of the following:

  • lbc.Region(...)
  • lbc.Department(...)
  • lbc.City(...)

Each one corresponds to a different level of geographic granularity.

City example

location = lbc.City(
    lat=48.85994982004764,
    lng=2.33801967847424,
    radius=10_000,  # in meters
    city="Paris"
)

Region / Department example

from lbc import Region, Department

region = Region.ILE_DE_FRANCE
department = Department.PARIS

403 Error

If you encounter a 403 Forbidden error, it usually means your requests are being blocked by Datadome. To resolve this:

  • Try reducing the request frequency (add delays between requests).
  • If you're using a proxy, make sure it is clean and preferably located in France.

Using residential or mobile proxies can also help avoid detection.

License

This project is licensed under the MIT License.

Support

Buy Me A Coffee

You can contact me via Telegram or Discord if you need help with scraping services or want to write a library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lbc-1.0.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lbc-1.0.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file lbc-1.0.1.tar.gz.

File metadata

  • Download URL: lbc-1.0.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lbc-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f62a437d0943f8b94a946737d57cdf88328ade8c8c898be6c4b0e1f4aae6734f
MD5 dbda99a2762a2617bd6d1249515f0b6b
BLAKE2b-256 4e07e825ceeb71956f59136b954942800745dc916c6f72e0eaeeaeaf785e868b

See more details on using hashes here.

File details

Details for the file lbc-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lbc-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lbc-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a847115975e21aa0ee62b4e6bb4015e0744c5ea83ac41ad95091f954f721283
MD5 3cd3dcf5b63ff36e629d0260fdfd4e33
BLAKE2b-256 c7677f8fe310a538627f5f1ac70927b29bf48a7eb4a41f30235bf75e71d1c793

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page