Y
Y
YraganTron2016-06-11 18:56:46
Python
YraganTron, 2016-06-11 18:56:46

How to write an algorithm that would collect the id of friends of my friends, etc.?

Interested in such an algorithm in depth in n.

deep = 0
id_1 = [id]
id_2 = []

while deep != 2:
    for x in range(len(id_1)):
        if api.users.get(user_ids=id_1[x])[0].get('deactivated', 0) == 0:
            id_2.extend(api.friends.get(user_id=id_1[x]))
    id_1 = id_2.copy()
    id_2.clear()
    deep += 1

When deep is greater than 2, it gives several errors. How to fix?
Mistakes
TypeError: getresponse() got an unexpected keyword argument 'buffering'

ConnectionResetError: [WinError 10054] Удаленный хост принудительно разорвал существующее подключение

requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'Удаленный хост принудительно разорвал существующее подключение', None, 10054, None))

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'Удаленный хост принудительно разорвал существующее подключение', None, 10054, None))

PS It used to give other errors

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question