Answer the question
In order to leave comments, you need to log in
How to write exception handling for VK API Error 18 "User was deleted or banned" error?
Here is the code (using the vk_requests library) trying to get the IDs of users' friends from the list of ids:
all_ids = list()
for id_ in tqdm(ids):
counts = api.friends.get(user_id=id_, count=0)['count'] # look at mount of friends
cycle = min(10, ceil(counts/1000)) # create var with counter which define number of cycles
for i in range(cycle):
shift = 0 # var for offset
friends = api.friends.get(user_id=id_, offset=shift, count=1000)['items'] # get the 1000 friends
for friend in friends:
all_ids.append(friend)
VkAPIError: error_code=18,message='User was deleted or banned',request_params={'method': 'friends.get', 'oauth': '1', 'v': '5.92', 'user_id': ' 11475787', 'count': '0'}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question