Exemple #1
0
 def find_by_city(self, city, cat, keywords):
     """
     Find items by city
     :param city: city
     :param cat: category
     :param keywords: keywords
     """
     print('--------{}:{}------'.format(city, cat))
     city_items = CityItems(city, cat, keywords)
     text = self.xrequests.get(city_items.url)
     if text:            
         scraper = HtmlScraper(text)
         for path in scraper.item_paths:
             item = scraper.scrape_item(path, keywords)
             if item:
                 print item
                 city_items.add_item(item)
     else:
         print 'ERROR: Invalid city: {}'.format(city)
     return city_items
Exemple #2
0
def find_by_city(city, cat, keywords):
    """
    Find items by city
    :param city: city
    :param cat: category
    :param keywords: keywords
    """
    print "--------------------------------------------------------"
    city_items = CityItems(city, cat)
    r = requests.get(city_items.url)
    if r.status_code == 200:
        scraper = HtmlScraper(r.text)
        for path in scraper.item_paths:
            item = scraper.scrape_item(path, keywords)
            if item:
                print item
                city_items.add_item(item)
    else:
        print 'ERROR: Invalid city: {}'.format(city)
    return city_items