• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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 properties within 10kms of Dublin city centre

from daftlistings import Daft, SearchType

daft = Daft()

daft.set_location("Dublin City Centre", Distance.KM10)
daft.set_search_type(SearchType.RESIDENTIAL_RENT)

listings = daft.search(max_pages=1)

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

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.

More Repositories

1

tmdbv3api

A lightweight Python library for The Movie Database (TMDb) API. The TMDb API is a resource for developers to integrate movie, TV show and cast data along with posters or movie fan art.
Python
219
star
2

zoopla

An API to allow developers to create applications using hyper local data on 27m homes, over 1m sale and rental listings, and 15 years of sold price data in the UK.
Python
80
star
3

ezflix

Command line utility that enables users to search for TV and movie torrents and stream using Peerflix automatically.
Python
46
star
4

python-cli-template

A starting point for building Python Command Line Applications.
Python
39
star
5

rcp

Python client for RealClearPolitics.
Python
26
star
6

nrql-simple

nrql-simple provides a convenient way to interact with the New Relic Insights query API.
Python
12
star
7

nrql-cli

An interactive command line interface for querying New Relic Insights event data.
Python
8
star
8

recommender

Python client for the Spotify Recommendations API.
Python
7
star
9

github-traffic-insights

Lambda function to send your Github traffic statistics to New Relic Insights.
Python
7
star
10

smartmove-api

An API to retrieve property price statistics in Ireland and the UK.
Python
6
star
11

tweet-generator

A small Python program to generate tweets.
Python
5
star
12

covid-cli

Get the latest COVID-19 information via the command line.
Python
3
star
13

dashboard-email-scheduler

Using New Relic NerdGraph, customers can now retrieve a PDF or image of a given New Relic Dashboard programmatically. This project provides the ability to periodically share a New Relic Dashboard using the GMail API.
Python
3
star
14

fitness-insights-dashboard

I have started to track my daily intake and exercise using MyFitnessPal and other mobile apps. This project pulls data from those sources and sends to New Relic Insights. This allows me to create visualisations and query my fitness and intake data using NRQL.
Python
3
star
15

recommender-client

Music recommendation client powered using the Spotify Recommendations API.
JavaScript
2
star
16

dashboard-exporter

A Python client to export a New Relic dashboard PDF or image programmatically.
Python
1
star
17

setup

My OS setup, including dotfiles and sane defaults for macOS.
Shell
1
star
18

nrscrapy

Monitor Scrapy using the New Relic Python Agent API
Python
1
star