Example #1
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
 def test_has_link(self):
     html_str = '<html><body><input type="submit" class="submit" name="submit" value="« edellinen sivu"><input type="submit" class="submit" name="submit" value="seuraava sivu »"></body></html>'
     self.assertEqual(parser.has_next_link(html_str), True)
 def test_has_not_link(self):
     html_str = (
         '<html><body><input type="submit" class="submit" name="submit" value="« edellinen sivu"></body></html>'
     )
     self.assertEqual(parser.has_next_link(html_str), False)