chris-greening/instascrape

_static_scraper.py wrong json data argument is passed

katepratik opened this issue · 1 comments

_static_scraper.py line no. 155

scraped_dict = parse_data_from_json(
                json_dict=flat_json_dict,
                map_dict=mapping,
            )

flat_json_dict object is passed in the argument. Expected argument is json_dict.
As wrong argument is passed the _mappings.py is returning nan for some of the mapped keys.

For example :
Key "caption" in following function will be nan as flat_json_dict is passed.

    @classmethod
    def post_from_hashtag_mapping(cls):
        """
        Return the mapping needed for parsing a post's JSON data from the JSON
        served back after requesting a Hashtag page.
        """
        return {
            "comments_disabled": deque(["comments_disabled"]),
            "id": deque(["id"]),
            "caption": deque(["edge_media_to_caption", "edges", 0, "node", "text"]),
            "shortcode": deque(["shortcode"]),
            "comments": deque(["edge_media_to_comment", "count"]),
            "upload_date": deque(["taken_at_timestamp"]),
            "dimensions": deque(["dimensions"]),
            "height": deque(["height"]),
            "width": deque(["width"]),
            "display_url": deque(["display_url"]),
            "likes": deque(["edge_media_preview_like_count"]),
            "owner": deque(["owner_id"]),
            "is_video": deque(["is_video"]),
            "accessibility_caption": deque(["accessibility_caption"]),
        }

I have this error when trying to retrieve the captions of a user's posts, anyone have a solution?