From 90cfeaf471ed2d7f556f7d9e2d1c8ffa0f685968 Mon Sep 17 00:00:00 2001 From: twitter-79 <42436876+twitter-79@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:12:07 +0200 Subject: [PATCH] Fixed fetching a users profile information (#1561) * fixed fetching a users profile information switched to new api/v1/users/web_profile_info/?username=xy endpoint * fixed non existing users thanks to @Dibort for fixing this! --- instaloader/structures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index 3957368..ba16b0a 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -764,8 +764,11 @@ class Profile: def _obtain_metadata(self): try: if not self._has_full_metadata: - metadata = self._context.get_json('{}/feed/'.format(self.username), params={}) - self._node = metadata['entry_data']['ProfilePage'][0]['graphql']['user'] + metadata = self._context.get_iphone_json(f'api/v1/users/web_profile_info/?username={self.username}', + params={}) + if metadata['data']['user'] is None: + raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) + self._node = metadata['data']['user'] self._has_full_metadata = True except (QueryReturnedNotFoundException, KeyError) as err: top_search_results = TopSearchResults(self._context, self.username)