Exemplo n.º 1
0
def get_house_list(zipcode, listing_type, criteria_list):
    '''
    This combines all functions involved in getting a list of House objects
    based on user inputs from the website

    Inputs
    zipcode: zipcode within which the user wants the search
    listing_type: either "sale" or "rent"
    criteria_list: list of lists that sets each condition
    e.g. [["price", 1000, 2000], ["bedroom", 1, 3], ["size", 800, 1000], 
          ["house_type", "houses", "apartments", "condos/co-ops"]]
    for numerical variable, the two number represents lower/upper bound
    for categorical variable, possible values are listed in order of preference
    
    Returns
    The list of House objects
    '''
    # The first three functions are explained in zillow.py
    url = zillow.create_url(zipcode, listing_type, criteria_list)
    soup = zillow.get_soup(url)
    house_list = zillow.create_house_objects(soup, url)
    # Return a new house list after filtering houses for the last time
    # Using the same criteria_list
    # The reason for this last filtering will be explained later
    new_house_list = filter_house(house_list, criteria_list)
    return new_house_list