dimanche 29 novembre 2020

instagram bot TypeError: argument of type 'NoneType' is not iterable

def getTopPosts(self):
    for hashtag in self.hashtags:
        self.browser.get('https://www.instagram.com/explore/tags/'+hashtag+'/')
        time.sleep(5)
        
        links = self.browser.find_elements_by_tag_name('a')
        condition = lambda link: '.com/p/' in link.get_attribute('herf')
        valid_links = list(filter(condition, links))

        for i in range (0,9):
            link = valid_links[i].get_attribute('href')
            if link not in self.links:
                self.links.append(links)

im always getting the TypeError: argument of type 'NoneType' is not iterable error when im running the code above i assume the problem is in the conition variable.

any idea how can i fix it?

my aim is to get the links in a page and then add them to a list.




Aucun commentaire:

Enregistrer un commentaire