示例#1
0
    def getPropertyFromZpid(self, zpid):
        url = "http://www.zillow.com/homes/" + zpid + "_zpid/"
        response = requests.get(url)
        html = response.content
        #html = '<html><body><div class="something-else"><div class=" status-icon-row for-sale-row home-summary-row"></div><div class=" home-summary-row"><span class=""> $1,342,144 </span></div></div></body></html>'
        #bad_soup = BeautifulSoup(html, "html5lib")
        #soup = BeautifulSoup(bad_soup.prettify(), "html5lib")
        soup = BeautifulSoup(html, "lxml")

        property = Property()
        property.setID(zpid)
        price = self.getPriceFromWebPage(soup)
        property.setPrice(price)
        rent = self.getRentFromWebPage(soup)
        property.setRent(rent)
        print(property.getRent())
        address, city, state, zip = self.getAddressFromWebPage(soup)
        property.setAddress(address)
        property.setCity(city)
        property.setState(state)
        property.setZip(zip)
        year, size, beds, baths = self.getOtherDetailsFromWebPage(soup)
        property.setYear(year)
        property.setSize(size)
        property.setBeds(beds)
        property.setBaths(baths)
        MLSNum = self.getMLSNumberFromWebPage(soup)
        property.setMLSNumber(MLSNum)
        isPreForeclosure = self.getIsPreForeclosureFromWebpage(soup)
        property.setIsPreForeclosure(isPreForeclosure)

        return property