DEV Community

Author Wong
Author Wong

Posted on

Scraping similar accounts on Instagram

Hi everyone! I'm currently have started a scraping side project which scrape similar account on instagram. My approach is using selenium and recursion methods to scrape those accounts. But I get stuck in doing that recursively, can anyone give me some advice what should I look for to complete this project.
Here is my code:

def grabbing(nms):
    usr_lnk = ["https://www.instagram.com/{}".format(n.text.split('\n')[0]) for n in a]
    def grabOne():
        nonlocal usr_lnk
        for lnk in usr_lnk:
            driver.get(lnk)
            try:
                wb = driver.find_element_by_class_name("yLUwa").text
                print(wb)
                time.sleep(15)
            except NoSuchElementException:
                pass
        pass
    return grabOne

Enter fullscreen mode Exit fullscreen mode

Top comments (0)