def get_subscribers_count(self, link, internal_id=None): screen_name = Crawler.get_screen_name(link) info = self.get_raw_info(screen_name=screen_name) subscribers = { 'updated_at': datetime.now().astimezone().strftime('%Y-%m-%dT%H:%M:%S%z'), 'count_subscribers': info['edge_followed_by']['count'] } return subscribers
def get_subscribers_count(self, link, internal_id=None): screen_name = Crawler.get_screen_name(link) user_info = self.get_raw_info(screen_name=screen_name) key_exist = 'legacy' in user_info['data']['user'] if not key_exist: raise GetInfoError(f'Ошибка получения подписчиков') info = user_info['data']['user']['legacy'] subscribers = { 'updated_at': datetime.now().astimezone().strftime('%Y-%m-%dT%H:%M:%S%z'), 'count_subscribers': info['followers_count'] } return subscribers
def get_info(self, link, internal_id=None): screen_name = Crawler.get_screen_name(link) info = self.get_raw_info(screen_name=screen_name) parsed_info = { 'name': info['full_name'], 'link': f'https://www.instagram.com/{info["username"]}', 'internal_id': info['id'], 'avatar': info['profile_pic_url'], 'type_social': 'IN', } if info['full_name'] == '': parsed_info.update({'name': info['username']}) if not parsed_info['avatar']: parsed_info.update({'avatar': info['profile_pic_url_hd']}) return parsed_info
def get_info(self, link, internal_id=None): screen_name = Crawler.get_screen_name(link) user_info = self.get_raw_info(screen_name=screen_name) user_id = user_info['data']['user']['rest_id'] key_exist = 'legacy' in user_info['data']['user'] if not key_exist: raise GetInfoError(f'Ошибка получения информации об аккаунте') info = user_info['data']['user']['legacy'] parsed_info = { 'name': info['name'], 'link': f'https://twitter.com/{info["screen_name"]}', 'internal_id': str(user_id), 'avatar': (info['profile_image_url_https']).replace('_normal', ''), 'type_social': 'TW', } if info['name'] == '': parsed_info.update({'name': info['screen_name']}) return parsed_info
def get_internal_id(self, link): screen_name = Crawler.get_screen_name(link) info = self.get_raw_info(screen_name=screen_name) return info['id']