Skip to main content

A library that enables programmatic interaction with daft.ie. Daft.ie has nationwide coverage and contains about 80% of the total available properties in Ireland.

Project description

Daftlistings

Build Status codecov

A library that enables programmatic interaction with Daft.ie. Daft.ie has nationwide coverage and contains about 80% of the total available properties in Ireland.

Installation

Daftlistings is available on the Python Package Index (PyPI). You can install daftlistings using pip.

virtualenv env
source env/bin/activate
pip install daftlistings

To install the development version, run:

pip install https://github.com/AnthonyBloomer/daftlistings/archive/dev.zip

Usage

from daftlistings import Daft

daft = Daft()
listings = daft.search()

for listing in listings:
    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 the max_pages argument.

daft.search(max_pages=1)

Examples

Search for apartments for rent in Dublin.

from daftlistings import Daft, Location, SearchType, PropertyType

daft = Daft()
daft.set_location(Location.DUBLIN)
daft.set_search_type(SearchType.RESIDENTIAL_RENT)
daft.set_property_type(PropertyType.APARTMENT)

listings = daft.search()

for listing in listings:
    print(listing.title)
    print(listing.price)
    print(listing.daft_link)

Search for houses for sale in Dublin between 400 and 500k.

from daftlistings import Daft, Location, SearchType, PropertyType

daft = 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()

for listing in listings:
    print(listing.title)
    print(listing.price)
    print(listing.daft_link)

Search for student accomodation near Dundalk IT.

from daftlistings import Daft, Location, SearchType

daft = Daft()
daft.set_location(Location.DUNDALK_INSTITUTE_OF_TECHNOLOGY_LOUTH)
daft.set_search_type(SearchType.STUDENT_ACCOMMODATION)

listings = daft.search()

for listing in listings:
    print(listing.title)
    print(listing.price)
    print(listing.daft_link)

Search for commercial listings.

from daftlistings import Daft, SearchType

daft = Daft()
daft.set_search_type(SearchType.COMMERCIAL_SALE)

listings = daft.search()

for listing in listings:
    print(listing.title)
    print(listing.price)
    print(listing.daft_link)
    print()

Search properties according to criteria then sort by nearness to Dublin Castle

from daftlistings import Daft, SearchType

daft = 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=lambda x: x.distance_to(dublin_castle_coords))

for listing in listings:
    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 rental properties in Dublin with monthly rent lower than 1500 euros and visualize it on a map

import pandas as pd
from daftlistings import Daft, Location, SearchType, PropertyType, SortType, MapVisualization


daft = 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 file
with open("result.txt", "w") as fp:
    fp.writelines("%s\n" % listing.as_dict_for_mapping() for listing in listings)

# read from the local file
with open("result.txt") as fp:
  lines = fp.readlines()

properties = []
for line in lines:
  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.

from daftlistings import Daft, Location, SearchType, PropertyType, Facility

daft = 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()

for listing in listings:
    print(listing.title)
    print(listing.price)
    print(listing.daft_link)
    print()

Running Tests

The Python unittest module contains its own test discovery function, which you can run from the command line:

python -m unittest discover tests/

Contributing

  • Fork 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.

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

daftlistings-2.0.0.tar.gz (96.1 kB view details)

Uploaded Source

Built Distribution

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

daftlistings-2.0.0-py2.py3-none-any.whl (96.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file daftlistings-2.0.0.tar.gz.

File metadata

  • Download URL: daftlistings-2.0.0.tar.gz
  • Upload date:
  • Size: 96.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for daftlistings-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d186ae5fd91ceb5cbec2be91eea626c521ee0797f210f16228c0325d4ee3258b
MD5 de42b83f3807396655a98c268d74ca6c
BLAKE2b-256 df627ae36d3d0364ebc193db2c3ecf3d218cfe12b8683b25326129d234de151c

See more details on using hashes here.

File details

Details for the file daftlistings-2.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: daftlistings-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 96.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for daftlistings-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b3e80aadd95ac1b789ff38616560bbbe265a81055491c632b5319443282951d0
MD5 0428bad2546e910d46c090567c4ed5ad
BLAKE2b-256 0a8e4c6c1aab36b026a5a6108e13f9e0f20db996611d1ea3176661c1ae582cdc

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