Ivan Kudryakov commited on
Commit
fa4d520
·
1 Parent(s): c28d0d4
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -32,8 +32,18 @@ st.write("wait about a minute we could do only 3 request per second")
32
  params_for_users_get = {'user_ids': my_id,
33
  'access_token': access_token,
34
  'v': api_version}
35
-
36
- myFirstAndLastName = requests.get('https://api.vk.com/method/users.get', params=params_for_users_get)
 
 
 
 
 
 
 
 
 
 
37
  # print(myFirstAndLastName.text)
38
 
39
  params_for_friends_get = {'user_id': my_id,
@@ -41,11 +51,18 @@ params_for_friends_get = {'user_id': my_id,
41
  'fields': 'sex',
42
  'access_token': access_token,
43
  'v': api_version}
44
-
45
- r = requests.get('https://api.vk.com/method/friends.get', params=params_for_friends_get)
46
- if 'error' in r.json() and r.json()['error']['error_code'] == 30:
47
- print('This is private profile, sorry')
48
- exit()
 
 
 
 
 
 
 
49
  print(r.text)
50
  AllMyFriends = r.json()['response']['items']
51
  # print(AllMyFriends[0]['id'])
 
32
  params_for_users_get = {'user_ids': my_id,
33
  'access_token': access_token,
34
  'v': api_version}
35
+ while True:
36
+ myFirstAndLastName = requests.get('https://api.vk.com/method/users.get', params=params_for_users_get)
37
+ if 'error' in myFirstAndLastName.json() and myFirstAndLastName.json()['error']['error_code'] == 30:
38
+ st.write('This is private profile, sorry')
39
+ exit()
40
+ if 'error' in myFirstAndLastName.json() and myFirstAndLastName.json()['error']['error_code'] == 6:
41
+ time.sleep(0.8)
42
+ continue
43
+ if 'error' in myFirstAndLastName.json():
44
+ st.write('unexpected error')
45
+ exit()
46
+ break
47
  # print(myFirstAndLastName.text)
48
 
49
  params_for_friends_get = {'user_id': my_id,
 
51
  'fields': 'sex',
52
  'access_token': access_token,
53
  'v': api_version}
54
+ while True:
55
+ r = requests.get('https://api.vk.com/method/friends.get', params=params_for_friends_get)
56
+ if 'error' in r.json() and r.json()['error']['error_code'] == 30:
57
+ st.write('This is private profile, sorry')
58
+ exit()
59
+ if 'error' in r.json() and r.json()['error']['error_code'] == 6:
60
+ time.sleep(0.8)
61
+ continue
62
+ if 'error' in r.json():
63
+ st.write('unexpected error')
64
+ exit()
65
+ break
66
  print(r.text)
67
  AllMyFriends = r.json()['response']['items']
68
  # print(AllMyFriends[0]['id'])