Package: daftlistings
DaftlistingsA library that enables programmatic interaction withDaft.ie. Daft.ie has nationwide coverage and contains about 80% of the total available properties in Ireland.InstallationDaftlistings is available on thePython Package Index (PyPI). You can install daftlistings using pip.virtualenvenvsourceenv/bin/activate
pipinstalldaftlistingsTo install the development version, run:pipinstallhttps://github.com/AnthonyBloomer/daftlistings/archive/dev.zipUsagefromdaftlistingsimportDaftdaft=Daft()listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)# ...By default, the Daft search function iterates over each page of results and appends each Listing object to the array that is returned. If you wish to limit the number of results that are returned you can use themax_pagesargument.daft.search(max_pages=1)ExamplesSearch for apartments for rent in Dublin.fromdaftlistingsimportDaft,Location,SearchType,PropertyTypedaft=Daft()daft.set_location(Location.DUBLIN)daft.set_search_type(SearchType.RESIDENTIAL_RENT)daft.set_property_type(PropertyType.APARTMENT)listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)Search for houses for sale in Dublin between 400 and 500k.fromdaftlistingsimportDaft,Location,SearchType,PropertyTypedaft=Daft()daft.set_location(Location.DUBLIN)daft.set_search_type(SearchType.RESIDENTIAL_SALE)daft.set_property_type(PropertyType.HOUSE)daft.set_min_price(400000)daft.set_max_price(500000)listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)Search for student accomodation near Dundalk IT.fromdaftlistingsimportDaft,Location,SearchTypedaft=Daft()daft.set_location(Location.DUNDALK_INSTITUTE_OF_TECHNOLOGY_LOUTH)daft.set_search_type(SearchType.STUDENT_ACCOMMODATION)listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)Search for commercial listings.fromdaftlistingsimportDaft,SearchTypedaft=Daft()daft.set_search_type(SearchType.COMMERCIAL_SALE)listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)print()Search properties according to criteria then sort by nearness to Dublin CastlefromdaftlistingsimportDaft,SearchTypedaft=Daft()daft.set_location("Dublin City")daft.set_search_type(SearchType.RESIDENTIAL_RENT)daft.set_min_price(1000)daft.set_max_price(1500)listings=daft.search(max_pages=1)dublin_castle_coords=[53.3429,-6.2674]listings.sort(key=lambdax:x.distance_to(dublin_castle_coords))forlistinginlistings:print(f'{listing.title}')print(f'{listing.daft_link}')print(f'{listing.price}')print(f'{listing.distance_to(dublin_castle_coords):.3}km')print('')Search properties within 10kms of Dublin city centrefromdaftlistingsimportDaft,SearchTypedaft=Daft()daft.set_location("Dublin City Centre",Distance.KM10)daft.set_search_type(SearchType.RESIDENTIAL_RENT)listings=daft.search(max_pages=1)forlistinginlistings:print(f'{listing.title}')print(f'{listing.daft_link}')print(f'{listing.price}')print('')Search rental properties in Dublin with monthly rent lower than 1500 euros and visualize it on a mapimportpandasaspdfromdaftlistingsimportDaft,Location,SearchType,PropertyType,SortType,MapVisualizationdaft=Daft()daft.set_location(Location.DUBLIN)daft.set_search_type(SearchType.RESIDENTIAL_RENT)daft.set_sort_type(SortType.PRICE_ASC)daft.set_max_price(1500)listings=daft.search()# cache the listings in the local filewithopen("result.txt","w")asfp:fp.writelines("%s\n"%listing.as_dict_for_mapping()forlistinginlistings)# read from the local filewithopen("result.txt")asfp:lines=fp.readlines()properties=[]forlineinlines:properties.append(eval(line))df=pd.DataFrame(properties)print(df)dublin_map=MapVisualization(df)dublin_map.add_markers()dublin_map.add_colorbar()dublin_map.save("ireland_rent.html")print("Done, please checkout the html file")Search for apartments for rent in Dublin with an alarm and parking.fromdaftlistingsimportDaft,Location,SearchType,PropertyType,Facilitydaft=Daft()daft.set_location(Location.DUBLIN)daft.set_search_type(SearchType.RESIDENTIAL_RENT)daft.set_property_type(PropertyType.APARTMENT)daft.set_facility(Facility.PARKING)daft.set_facility(Facility.ALARM)listings=daft.search()forlistinginlistings:print(listing.title)print(listing.price)print(listing.daft_link)print()Running TestsThe Python unittest module contains its own test discovery function, which you can run from the command line:python -m unittest discover tests/ContributingFork the project and clone locally.Create a new branch for what you're going to work on.Push to your origin repository.Create a new pull request in GitHub.Note: We use (Black)[https://github.com/psf/black] for code formatting. After making any changes to the code, it is important for you to ensure that it passes Black's lint check.