Esempio n. 1
0
class FlickrPaginator:
    def __init__(self, query):
        self.crawler = FlickrCrawler()
        self.query = query
        self.pages = 0
        self.page = 0

    def __iter__(self):
        return self

    def next(self):
        print "Next page is activated"
        pagination_struct = self.crawler.delay(self.query, self.page).get()
        print pagination_struct
        self.pages = pagination_struct["pages"]

        self.page += 1
        if self.page < self.pages:
            return pagination_struct["urls"]
        else:
            raise StopIteration()
Esempio n. 2
0
 def __init__(self, query):
     self.crawler = FlickrCrawler()
     self.query = query
     self.pages = 0
     self.page = 0