def test(self):
     html_str = create_html_str()
     prices = parser.parse_prices(html_str, "Helsinki", "00510")
     self.assertEqual(len(prices), 1)
     self.assertEqual(prices[0]["city"], "Helsinki")
     self.assertEqual(prices[0]["postal_code"], "00510")
     self.assertEqual(prices[0]["neighborhood"], "Lauttasaari")
Beispiel #2
0
def insert_prices(city, postal_code):
    index = 1
    next_page = True
    while next_page:
        printer('Fetching prices with city {0} and postal code {1}'.format(city, postal_code))
        html_page = prices_access.load_html(postal_code, index)
        prices = parser.parse_prices(html_page, city, postal_code)
        exporter.print_prices(prices, printer)
        db_access.insert_prices(prices)
        if (parser.has_next_link(html_page)):
            index += 1
        else:
            next_page = False