Пример #1
0
 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)
Пример #2
0
 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)
Пример #4
0
 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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
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.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)
Пример #13
0
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
Пример #14
0
    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)
Пример #15
0
 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)
Пример #16
0
 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)
Пример #17
0
    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)
Пример #18
0
    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)
Пример #19
0
    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)
Пример #20
0
 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)
Пример #21
0
    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)
Пример #22
0
# 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(' ')
Пример #23
0
# 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
Пример #24
0
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)
Пример #26
0
# 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(' ')
Пример #27
0
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(" ")
Пример #28
0
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)
Пример #29
0
# 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(" ")