InstaPy / instagram-profilecrawl

📝 quickly crawl the information (e.g. followers, tags etc...) of an instagram profile.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't pull posts

eyau77 opened this issue · comments

It seems that posts are not being scraped. I am trying to scrap a user's posts to grab a list of who liked the post.

I traced to the function quick_post_extract in extractor.py:

while (posts_set_len < num_of_posts_to_do):
    print(posts_set_len)

    JSGetPostsFromReact = """
        var feed = document.getElementsByTagName('article')[0];
        var __reactInternalInstanceKey = Object.keys(feed).filter(k=>k.startsWith('__reactInternalInstance'))[0]
        var posts = feed[__reactInternalInstanceKey].return.stateNode.state.combinedPosts
        return posts;
    """
    posts_json = browser.execute_script(JSGetPostsFromReact)

posts_json returns an empty array. Perhaps the Javascript has become outdated?

Tried the javascript code in the browser and it indeed returns an empty array.

Thank you for this amazing library and Instapy!

Ed

Was having the same problem. After tinkering for a bit with Inspect Element on the Instagram page on browser, I found that there are 2 elements with tag name 'article'. One is empty, the other contains posts. By simply changing 0 to 1 in var feed = document.getElementsByTagName('article')[0]; I am able to get posts.

I don't know if this is environment/browser specific though. Any insights will be appreciated.