diff --git a/examples/get_ad.py b/examples/get_ad.py index 72dabe0..95fecd2 100644 --- a/examples/get_ad.py +++ b/examples/get_ad.py @@ -2,6 +2,7 @@ import lbc + def main() -> None: # Initialize the Leboncoin API client client = lbc.Client() @@ -18,5 +19,6 @@ def main() -> None: # Print information about the user who posted the ad print("User info:", ad.user) + if __name__ == "__main__": main() diff --git a/examples/get_user.py b/examples/get_user.py index 4b76c24..b02d31e 100644 --- a/examples/get_user.py +++ b/examples/get_user.py @@ -2,6 +2,7 @@ import lbc + def main() -> None: # Initialize the Leboncoin API client client = lbc.Client() @@ -16,5 +17,6 @@ def main() -> None: print("Pro status:", user.is_pro) print("Ads count:", user.total_ads) + if __name__ == "__main__": main() diff --git a/examples/proxy.py b/examples/proxy.py index 6d58d15..e26a0f9 100644 --- a/examples/proxy.py +++ b/examples/proxy.py @@ -1,29 +1,31 @@ import lbc + def main() -> None: - # Setup proxy1 - proxy1 = lbc.Proxy( - host="127.0.0.1", - port=12345, - username="username", - password="password", - scheme="http" - ) + # Setup proxy1 + proxy1 = lbc.Proxy( + host="127.0.0.1", + port=12345, + username="username", + password="password", + scheme="http", + ) - # Initialize client with proxy1 - client = lbc.Client(proxy=proxy1) + # Initialize client with proxy1 + client = lbc.Client(proxy=proxy1) - # Setup proxy2 - proxy2 = lbc.Proxy( - host="127.0.0.1", - port=23456, - ) + # Setup proxy2 + proxy2 = lbc.Proxy( + host="127.0.0.1", + port=23456, + ) - # Change client proxy to proxy2 - client.proxy = proxy2 + # Change client proxy to proxy2 + client.proxy = proxy2 + + # Remove proxy + client.proxy = None - # Remove proxy - client.proxy = None if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/examples/search_with_args.py b/examples/search_with_args.py index dbaa94a..26b2196 100644 --- a/examples/search_with_args.py +++ b/examples/search_with_args.py @@ -2,6 +2,7 @@ import lbc + def main() -> None: # Initialize the Leboncoin API client client = lbc.Client() @@ -11,28 +12,29 @@ def main() -> None: lat=48.85994982004764, lng=2.33801967847424, radius=10_000, # 10 km - city="Paris" + city="Paris", ) # Perform a search with various filters result = client.search( - text="maison", # Search for houses - locations=[location], # Only in Paris + text="maison", # Search for houses + locations=[location], # Only in Paris page=1, - limit=35, # Max results per page - limit_alu=0, # No auto-suggestions - sort=lbc.Sort.NEWEST, # Sort by newest ads - ad_type=lbc.AdType.OFFER, # Only offers, not searches - category=lbc.Category.IMMOBILIER, # Real estate category - owner_type=lbc.OwnerType.ALL, # All types of sellers - search_in_title_only=True, # Only search in titles - square=(200, 400), # Surface between 200 and 400 m² - price=[300_000, 700_000] # Price range in euros + limit=35, # Max results per page + limit_alu=0, # No auto-suggestions + sort=lbc.Sort.NEWEST, # Sort by newest ads + ad_type=lbc.AdType.OFFER, # Only offers, not searches + category=lbc.Category.IMMOBILIER, # Real estate category + owner_type=lbc.OwnerType.ALL, # All types of sellers + search_in_title_only=True, # Only search in titles + square=(200, 400), # Surface between 200 and 400 m² + price=[300_000, 700_000], # Price range in euros ) # Display summary of each ad for ad in result.ads: print(f"{ad.id} | {ad.url} | {ad.subject} | {ad.price}€ | Seller: {ad.user}") + if __name__ == "__main__": main() diff --git a/examples/search_with_args_pro.py b/examples/search_with_args_pro.py index 02485ad..37abe12 100644 --- a/examples/search_with_args_pro.py +++ b/examples/search_with_args_pro.py @@ -2,6 +2,7 @@ import lbc + def main() -> None: # Initialize the Leboncoin API client client = lbc.Client() @@ -11,23 +12,23 @@ def main() -> None: lat=48.85994982004764, lng=2.33801967847424, radius=10_000, # 10 km - city="Paris" + city="Paris", ) # Perform a search with specific filters result = client.search( - text="maison", # Search for houses - locations=[location], # Only in Paris + text="maison", # Search for houses + locations=[location], # Only in Paris page=1, - limit=35, # Max results per page - limit_alu=0, # No auto-suggestions - sort=lbc.Sort.NEWEST, # Sort by newest ads - ad_type=lbc.AdType.OFFER, # Only offers, not searches - category=lbc.Category.IMMOBILIER, # Real estate category - owner_type=lbc.OwnerType.ALL, # All types of sellers - search_in_title_only=True, # Only search in titles - square=(200, 400), # Surface between 200 and 400 m² - price=[300_000, 700_000] # Price range in euros + limit=35, # Max results per page + limit_alu=0, # No auto-suggestions + sort=lbc.Sort.NEWEST, # Sort by newest ads + ad_type=lbc.AdType.OFFER, # Only offers, not searches + category=lbc.Category.IMMOBILIER, # Real estate category + owner_type=lbc.OwnerType.ALL, # All types of sellers + search_in_title_only=True, # Only search in titles + square=(200, 400), # Surface between 200 and 400 m² + price=[300_000, 700_000], # Price range in euros ) # Display only professional ads with their legal/professional data @@ -39,5 +40,6 @@ def main() -> None: f"Website: {ad.user.pro.website_url or 'N/A'}" ) + if __name__ == "__main__": main() diff --git a/examples/search_with_url.py b/examples/search_with_url.py index a02f7ee..b2c335a 100644 --- a/examples/search_with_url.py +++ b/examples/search_with_url.py @@ -2,6 +2,7 @@ import lbc + def main() -> None: # Initialize the Leboncoin API client client = lbc.Client() @@ -10,12 +11,13 @@ def main() -> None: result = client.search( url="https://www.leboncoin.fr/recherche?category=10&text=maison&locations=Paris__48.86023250788424_2.339006433295173_9256_30000", page=1, - limit=35 + limit=35, ) # Print basic info about each ad for ad in result.ads: print(f"{ad.id} | {ad.url} | {ad.subject} | {ad.price}€ | Seller: {ad.user}") + if __name__ == "__main__": main()