duccioa / python-seloger

A simple Seloger.com wrapper
MIT No Attribution
6 stars 1 forks source link

python-seloger

=================

A simple SeLoger wrapper.

License: MIT-Zero.

Installation

From the shell:

pip install git+https://github.com/duccioa/python-seloger

Depending on your system, you might want to try:

pip3 install git+https://github.com/duccioa/python-seloger

Or:

pip3 install -e git+https://github.com/duccioa/python-seloger#egg=egg_name

Classes

Base class:

Subclasses:

Every subclass links to the relevant search option.

Filters

Search filters have to be included in the form of a dictionary:

search_filters = {
    'url_key1': 'value1',
    'url_key2': 'value2'
    }

url_key is the API key for the search option (ex. 'tri' is the URL key for sorting) and value is the required values ('d_dt_crea' is the value for sorting by date).

To get a list of the URL keys, use the .show_search_options() class-method:

from SeLoger import show_search_filters

show_search_filters() # to prompt a selection

show_search_filters(selection="print_all") # to show all the filters

Examples

Let's find a 1 bedroom apartment for buying in the 15th Arrondissement of Paris, minimum 40 sqm and with a balcony at a maximum price of 500 000 euros.

from SeLoger import SeLogerAchat
from SeLoger import show_search_filters

# Check the syntax for the relevant search filters
show_search_filters()

search_criteria = {'cp': '75015', 'idtypebien': '1', 'pxmax': '500000', 'surfacemin': '40','tri': 'd_dt_crea', 'nb_balconsmin': '1'}

rent_paris = SeLogerAchat(search_criteria)
# get_results creates a generator that can be iterated and stored in a list
results = rent_paris.get_results(2, print_results=1)
ads = []
for result in results:
    ads.append(result)

Looking for an office in Marseille? Let's save the results as a Pandas dataframe.

from SeLoger import SeLogerLocation

search_criteria = {'cp': '33', 'idtypebien': '8', 'pxmax': '2000', 'surfacemin': '40', 'tri': 'd_dt_crea'}

office_marseille = SeLogerLocation(search_criteria, delay=5)
df = office_marseille.results_to_dataframe(4)

Future developments

Credits

This wrapper has been developed for study purposes, based on the python-craigslist scraper.

Support

For bugs or new features, please use the issues tracker. I welcome any contribution.