diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index ffca86e..a138092 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -351,10 +351,10 @@ class InstaloaderContext: raise ConnectionException("\"window._sharedData\" does not contain required keys.") # If GraphQL data is missing in `window._sharedData`, search for it in `__additionalDataLoaded`. if 'graphql' not in post_or_profile_page[0]: - match = re.search(r'window\.__additionalDataLoaded\([^{]+{"graphql":({.*})}\);', + match = re.search(r'window\.__additionalDataLoaded\(.*?({.*"graphql":.*})\);', resp.text) if match is not None: - post_or_profile_page[0]['graphql'] = json.loads(match.group(1)) + post_or_profile_page[0]['graphql'] = json.loads(match.group(1))['graphql'] return resp_json else: resp_json = resp.json() diff --git a/instaloader/structures.py b/instaloader/structures.py index 430aebb..78219a6 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -549,7 +549,7 @@ class Profile: """ # pylint:disable=protected-access profile = cls(context, {'username': username.lower()}) - profile._obtain_metadata() # to raise ProfileNotExistException now in case username is invalid + profile._obtain_metadata() # to raise ProfileNotExistsException now in case username is invalid return profile @classmethod