-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_user_info.py
30 lines (26 loc) · 1.12 KB
/
get_user_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
from constants import APP_ACCESS_TOKEN,BASE_URL
from get_user_id import get_user_id
from colorama import Fore,Style
def get_user_info(insta_username):
#function logic here
user_id = get_user_id(insta_username)
if user_id == None:
print 'User does not exist!'
exit()
else:
print 'successfully'
show== menu_choice
request_url = (BASE_URL + 'users/%s?access_token=%s') % (user_id, APP_ACCESS_TOKEN)
user_info = requests.get(request_url).json()
if user_info['meta']['code'] == 200:
if len(user_info['data']):
print '\nUsername: %s' % (user_info['data']['username'])
print '\nNo. of followers: %s' % (user_info['data']['counts']['followed_by'])
print '\nNo. of people you are following: %s' % (user_info['data']['counts']['follows'])
print '\nNo. of posts: %s' % (user_info['data']['counts']['media'])
else:
print Fore.RED+Style.BRIGHT+'There is no data for this user!'
else:
print Fore.RED+Style.BRIGHT+'Status code other than 200 received!'
#get_user_info(insta_username="radhika12344")