コード例 #1
0
 def test_properties_with_max_beds(self):
     daft = Daft()
     daft.set_county('Dublin')
     daft.set_min_beds(3)
     daft.set_max_beds(3)
     listings = daft.search()
     self.assertTrue(len(listings) > 0)
     listing = listings[0]
     self.assertTrue(listing.bedrooms == 3)
コード例 #2
0
ファイル: daft_utils.py プロジェクト: girodav/daft-slack
def initialize_daft_api_client():
    daft_client = Daft()
    daft_client.set_county(config.COUNTY)
    daft_client.set_listing_type(config.LISTING_TYPE)
    daft_client.set_min_price(config.MIN_PRICE)
    daft_client.set_max_price(config.MAX_PRICE)
    daft_client.set_with_photos(config.WITH_PHOTOS)
    daft_client.set_added_since(config.ADDED_SINCE)
    daft_client.set_area(config.AREAS)
    daft_client.set_sort_order(config.SORT_ORDER)
    daft_client.set_sort_by(config.SORT_BY)
    daft_client.set_furnished(config.FURNISHED)
    daft_client.set_min_beds(config.MIN_BEDS)
    daft_client.set_min_lease(config.MIN_LEASE)
    return daft_client
コード例 #3
0
    def test_search_properties_for_sale(self, mock_post):
        url = "https://search-gateway.dsch.ie/v1/listings"
        payload = {
            "section":
            "residential-for-sale",
            "andFilters": [{
                "name":
                "facilities",
                "values": [
                    "wired-for-cable-television",
                    "alarm",
                    "wheelchair-access",
                    "gas-fired-central-heating",
                ],
            }],
            "ranges": [
                {
                    "name": "salePrice",
                    "from": "250000",
                    "to": "300000"
                },
                {
                    "name": "numBeds",
                    "from": "3",
                    "to": "3"
                },
                {
                    "name": "ber",
                    "from": "0",
                    "to": "0"
                },
                {
                    "name": "floorSize",
                    "from": "1000",
                    "to": "1000"
                },
                {
                    "name": "firstPublishDate",
                    "from": "now-14d/d",
                    "to": ""
                },
            ],
            "geoFilter": {
                "storedShapeIds": ["3"],
                "geoSearchType": "STORED_SHAPES"
            },
            "sort":
            "priceAsc",
            "paging": {
                "from": "0",
                "pagesize": "50"
            },
        }
        headers = {
            "Content-Type": "application/json",
            "brand": "daft",
            "platform": "web",
        }

        daft = Daft()

        daft.set_search_type(SearchType.RESIDENTIAL_SALE)
        daft.set_location(Location.KILDARE)
        daft.set_location("Kildare")
        daft.set_sort_type(SortType.PRICE_ASC)
        daft.set_max_price(300000)
        daft.set_min_price(250000)
        daft.set_min_beds(3)
        daft.set_max_beds(3)
        daft.set_min_ber(Ber.A1)
        daft.set_max_ber(Ber.A1)
        daft.set_max_floor_size(1000)
        daft.set_min_floor_size(1000)
        daft.set_added_since(AddedSince.DAYS_14)
        daft.set_facility(Facility.WIRED_FOR_CABLE_TELEVISION)
        daft.set_facility(Facility.ALARM)
        daft.set_facility(Facility.WHEELCHAIR_ACCESS)
        daft.set_facility(Facility.CENTRAL_HEATING_GAS)
        daft.search()

        mock_post.assert_called_with(url, headers=headers, json=payload)
コード例 #4
0
    def test_search_properties_for_rent(self, mock_post):
        url = "https://search-gateway.dsch.ie/v1/listings"
        payload = {
            "section":
            "residential-to-rent",
            "andFilters": [{
                "name": "facilities",
                "values": ["alarm", "parking", "cable-television"],
            }],
            "ranges": [
                {
                    "name": "rentalPrice",
                    "from": "2000",
                    "to": "2500"
                },
                {
                    "name": "numBeds",
                    "from": "1",
                    "to": "2"
                },
                {
                    "name": "ber",
                    "from": "0",
                    "to": "0"
                },
                {
                    "name": "floorSize",
                    "from": "1000",
                    "to": "1000"
                },
                {
                    "name": "firstPublishDate",
                    "from": "now-14d/d",
                    "to": ""
                },
            ],
            "geoFilter": {
                "storedShapeIds": ["3"],
                "geoSearchType": "STORED_SHAPES"
            },
            "sort":
            "priceDesc",
            "paging": {
                "from": "0",
                "pagesize": "50"
            },
        }
        headers = {
            "Content-Type": "application/json",
            "brand": "daft",
            "platform": "web",
        }

        daft = Daft()

        daft.set_search_type(SearchType.RESIDENTIAL_RENT)
        daft.set_location(Location.KILDARE)
        daft.set_location("Kildare")
        daft.set_sort_type(SortType.PRICE_DESC)
        daft.set_max_price(2500)
        daft.set_min_price(2000)
        daft.set_min_beds(1)
        daft.set_max_beds(2)
        daft.set_min_ber(Ber.A1)
        daft.set_max_ber(Ber.A1)
        daft.set_max_floor_size(1000)
        daft.set_min_floor_size(1000)
        daft.set_added_since(AddedSince.DAYS_14)
        daft.set_facility(Facility.ALARM)
        daft.set_facility(Facility.PARKING)
        daft.set_facility(Facility.CABLE_TELEVISION)
        daft.search()

        mock_post.assert_called_with(url, headers=headers, json=payload)
コード例 #5
0
except:
    print(
        "[W] Unable to read cache file. Don't worry if you start from scretch."
    )

# search listings on daft
print("[*] Reading Daft.")
listings = []
offset = 0
daft = Daft()
try:
    daft.set_county(config["rent_county"])
    daft.set_area(config["rent_area"])
    daft.set_listing_type(RentType.ANY)
    daft.set_max_price(config["rent_max_price"])
    daft.set_min_beds(config["rent_min_bedroom"])
    daft.set_max_beds(config["rent_max_bedroom"])
except:
    print("[E] Configuration is broken.")
    sys.exit(-1)
while True:
    l = daft.search()
    if len(l) == 0:
        break
    for listing in l:
        if listing.daft_link in cached:
            continue
        listings.append(listing)
        cached[listing.daft_link] = ''
    offset += 20
    daft.set_offset(offset)
コード例 #6
0
ファイル: mapping_example.py プロジェクト: leej3/daftlistings
from daftlistings import Daft, SortOrder, SortType, RentType, MapVisualization
import pandas as pd

daft = Daft()
daft.set_county("Dublin City")
daft.set_listing_type(RentType.ANY)
daft.set_sort_order(SortOrder.ASCENDING)
daft.set_sort_by(SortType.PRICE)
# must sort by price in asending order, MapVisualization class will take care of the weekly/monthly value mess
daft.set_max_price(2400)
daft.set_min_beds(2)
daft.set_max_beds(2)

listings = daft.search()
properties = []
print(
    "Translating {} listing object into json, it will take a few minutes".format(
        str(len(listings))
    )
)
print("Igonre the error message")
for listing in listings:
    try:
        if listing.search_type != "rental":
            continue
        properties.append(listing.as_dict_for_mapping())
    except:
        continue


df = pd.DataFrame(properties)
コード例 #7
0
# Prepare a cursor object using cursor() method
cursor = db.cursor()

# Configure Daft.ie research
today = date.today()
area_array = [
    "Galway City Centre", "Galway City Suburbs", "Galway Commuter Towns"
]

for x in area_array:
    daft = Daft()
    daft.set_area(x)
    daft.set_county("Galway City")
    daft.set_listing_type(SaleType.HOUSES)
    daft.set_min_beds(3)
    daft.set_max_price(300000)

    print("## Searching in " + x)

    # Launch the research
    listings = daft.search()

    # List data in the database

    for listing in listings:
        try:
            beds = listing.bedrooms
            address = listing.formalised_address
            link = listing.daft_link
            price = listing.price