def test_properties(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_added_since(14) daft.set_listing_type(SaleType.PROPERTIES) daft.set_property_type([PropertyType.HOUSE]) listings = daft.search(fetch_all=False) self.assertTrue(len(listings) > 0) first = listings[1] self.assertIsNotNone(first.agent_id) self.assertIsNotNone(first.commercial_area_size) self.assertIsNotNone(first.contact_number) self.assertIsNotNone(first.daft_link) self.assertIsNotNone(first.date_insert_update) self.assertIsNotNone(first.facilities) self.assertIsNotNone(first.formalised_address) self.assertIsNotNone(first.id) self.assertIsNotNone(first.bathrooms) self.assertIsNotNone(first.bedrooms) self.assertIsNotNone(first.overviews) self.assertIsNotNone(first.price) self.assertIsNotNone(first.search_type) self.assertIsNotNone(first.shortcode) self.assertIsNotNone(first.views) self.assertIsNotNone(first.features) self.assertIsNotNone(first.advertiser_name) self.assertIsNotNone(first.date_insert_update) self.assertIsNotNone(first.hires_images) self.assertIsNotNone(first.images)
def test_properties(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) listings = daft.get_listings() self.assertTrue(len(listings) > 0)
def test_apartments_to_let(self): daft = Daft() daft.set_offset(20) daft.set_listing_type(RentType.APARTMENTS) daft.set_area("Malahide") listings = daft.search(fetch_all=False) search_count = daft.search_count self.assertGreater(search_count, 0) self.assertGreater(len(listings), 0) apartment = listings[0] print(apartment.daft_link) self.assertIsNotNone(apartment.commercial_area_size) self.assertIsNotNone(apartment.contact_number) self.assertIsNotNone(apartment.daft_link) self.assertIsNotNone(apartment.date_insert_update) self.assertIsNotNone(apartment.facilities) self.assertIsNotNone(apartment.formalised_address) self.assertIsNotNone(apartment.id) self.assertIsNotNone(apartment.bathrooms) self.assertIsNotNone(apartment.bedrooms) self.assertIsNotNone(apartment.overviews) self.assertIsNotNone(apartment.price) self.assertIsNotNone(apartment.search_type) self.assertIsNotNone(apartment.shortcode) self.assertIsNotNone(apartment.views) self.assertIsNotNone(apartment.features) self.assertIsNotNone(apartment.advertiser_name) self.assertIsNotNone(apartment.date_insert_update) self.assertIsNotNone(apartment.hires_images)
def test_area_commercial_properties(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.COMMERCIAL) listings = daft.get_listings() self.assertTrue(len(listings) > 0)
def test_properties_with_negative_max(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_max_price(-1000) daft.set_listing_type(SaleType.PROPERTIES) listings = daft.search() self.assertTrue(len(listings) == 0)
def test_apartments_to_let(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(RentType.APARTMENTS) listings = daft.get_listings() self.assertTrue(len(listings) > 0)
def test_properties_sale_agreed(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_sale_agreed(True) listings = daft.search() self.assertTrue(len(listings) > 0)
def test_room_to_share(self): daft = Daft() daft.set_county('Dublin') daft.set_area('Castleknock') daft.set_listing_type(RentType.ROOMS_TO_SHARE) daft.set_furnished(True) daft.set_min_price(500) daft.set_max_price(1000) daft.set_room_type(RoomType.DOUBLE) listings = daft.search() self.assertTrue(len(listings) > 0)
def test_properties_with_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(200000) daft.set_max_price(250000) listings = daft.search(fetch_all=False) self.assertTrue(len(listings) > 0) listing = listings[0] price = listing.price self.assertTrue(200000 <= int(price) <= 250000)
def test_apartments_to_let_with_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(RentType.APARTMENTS) daft.set_min_price(1000) daft.set_max_price(2000) listings = daft.search(fetch_all=False) self.assertTrue(len(listings) > 0) listing = listings[0] price = listing.price self.assertTrue(1000 <= int(price) <= 2000)
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.search(fetch_all=False) listing = listings[0] price = listing.price self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
def test_properties_with_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(200000) daft.set_max_price(250000) listings = daft.get_listings() self.assertTrue(len(listings) > 0) listing = listings[0] price = listing.get_price() price = price[1:] price = price.replace(',', '') self.assertTrue(200000 <= int(price) <= 250000)
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
def test_properties_sale_agreed_with_invalid_prices(self): daft = Daft() raised_exception = False daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_sale_agreed(True) try: daft.set_min_price("Two") daft.set_max_price("") daft.search() except: raised_exception = True self.assertTrue(raised_exception)
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.search() listing = listings[0] price = listing.price price = price.split() price = price[len(price) - 1] price = price[1:] price = price.replace(',', '') self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
def test_apartments_to_let_with_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(RentType.APARTMENTS) daft.set_min_price(1000) daft.set_max_price(2000) listings = daft.search() self.assertTrue(len(listings) > 0) listing = listings[0] price = listing.price price = price[1:] price = price.replace(',', '') if 'week' or 'month' in price: price = price.split() price = price[0] self.assertTrue(1000 <= int(price) <= 2000)
def test_properties_sale_agreed_with_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(200000) daft.set_max_price(250000) daft.set_sale_agreed(True) listings = daft.search() self.assertTrue(len(listings) > 0) listing = listings[0] price = listing.price price = price[1:] price = price.replace(',', '') self.assertTrue(200000 <= int(price) <= 250000) self.assertTrue('Dublin 15' in listing.formalised_address)
def test_sort_by_date_ascending(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_sort_order(SortOrder.ASCENDING) daft.set_sort_by(SortType.DATE) daft.set_min_price(150000) daft.set_max_price(175000) listings = daft.search() self.assertTrue(len(listings) > 0) first = listings[0].posted_since.split() last = listings[-1].posted_since.split() first_date = time.strptime(first[0], "%d/%m/%Y") last_date = time.strptime(last[0], "%d/%m/%Y") self.assertTrue(first_date < last_date)
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.get_listings() listing = listings[0] price = listing.get_price() if "AMV" in price: price = price[6:] else: price = price[1:] print price price = price.replace(',', '') self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
def test_properties(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_added_since(14) daft.set_listing_type(SaleType.PROPERTIES) listings = daft.search() self.assertTrue(len(listings) > 0) first = listings[1] self.assertIsNotNone(first.facilities) self.assertIsNotNone(first.formalised_address) self.assertIsNotNone(first.address_line_1) self.assertIsNotNone(first.address_line_2) self.assertIsNotNone(first.agent) self.assertIsNotNone(first.agent_id) self.assertIsNotNone(first.agent_url) self.assertIsNotNone(first.bathrooms) self.assertIsNotNone(first.bedrooms) self.assertIsNotNone(first.county) self.assertIsNotNone(first.daft_link) self.assertIsNotNone(first.features) self.assertIsNotNone(first.id) self.assertIsNotNone(first.search_type) self.assertIsNotNone(first.dwelling_type)
for i in f.readlines(): cached[i.strip()] = "" f.close() 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)
# Get properties to let near or on a public transport route to Blackrock. from daftlistings import Daft, AreaType, RentType daft = Daft() daft.set_area_type(AreaType.ENROUTE) daft.set_area('Dublin') daft.set_listing_type(RentType.ANY) listings = daft.search() for listing in listings: print(listing.formalised_address) print(listing.price) print(' ')
# Open database connection # Edit with your database credentials db = MySQLdb.connect("localhost", "<username>", "<password>", "daftlistings") # 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
from daftlistings import Daft, RentType, RoomType, Gender daft = Daft() daft.set_listing_type(RentType.ROOMS_TO_SHARE) daft.set_room_type(RoomType.DOUBLE) daft.set_furnished(True) daft.set_county('Dublin City') daft.set_area('Castleknock') daft.set_gender(Gender.MALE) daft.set_with_photos(True) listings = daft.search() for listing in listings: print(listing.price) print(listing.formalised_address) print(listing.daft_link) print(listing.contact_number) print(' ')
# Get the current sale agreed prices for properties in Dublin 15 that are between 200,000 and 250,000. from daftlistings import Daft, SaleType daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_sale_agreed(True) daft.set_min_price(200000) daft.set_max_price(250000) listings = daft.get_listings() for listing in listings: print(listing.get_formalised_address()) print(listing.get_daft_link()) facilities = listing.get_facilities() if facilities is not None: print('Facilities: ') for facility in facilities: print(facility) features = listing.get_features() if features is not None: print('Features: ') for feature in features: print(feature)
# Get properties to let near or on a public transport route to Blackrock. from daftlistings import Daft, AreaType, RentType daft = Daft() daft.set_area_type(AreaType.ENROUTE) daft.set_area('Blackrock') daft.set_listing_type(RentType.ANY) listings = daft.search() for listing in listings: print(listing.formalised_address) print(listing.price) print(' ')
from daftlistings import Daft, RentType, RoomType, Gender daft = Daft() daft.set_listing_type(RentType.ROOMS_TO_SHARE) daft.set_room_type(RoomType.DOUBLE) daft.set_furnished(True) daft.set_county("Dublin City") daft.set_area("Castleknock") daft.set_gender(Gender.MALE) daft.set_with_photos(True) listings = daft.search() for listing in listings: print(listing.price) print(listing.formalised_address) print(listing.daft_link) print(listing.contact_number) print(" ")
from daftlistings import Daft, RentType, Gender, SortOrder, SortType daft = Daft() areas = ['IFSC', 'Blackrock'] daft.set_county('Dublin City') daft.set_area(areas) daft.set_listing_type(RentType.ROOMS_TO_SHARE) daft.set_with_photos(True) daft.set_gender(Gender.MALE) daft.set_verbose(True) daft.set_sort_order(SortOrder.ASCENDING) daft.set_sort_by(SortType.PRICE) listings = daft.search() for listing in listings: print(listing.formalised_address) print(listing.price) print(listing.daft_link)
# Get properties to let near or on a public transport route to Blackrock. from daftlistings import Daft, AreaType, RentType daft = Daft() daft.set_area_type(AreaType.ENROUTE) daft.set_area("Dublin") daft.set_listing_type(RentType.ANY) listings = daft.search() for listing in listings: print(listing.formalised_address) print(listing.price) print(" ")