-
Notifications
You must be signed in to change notification settings - Fork 0
/
BFS.py
102 lines (68 loc) · 1.61 KB
/
BFS.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import requests
import os
headers = {
"Authorization": f"Bearer {os.environ['API_BEARER'].strip()}"
}
# https://api.twitter.com/2/users/by?username=sdjalsdjsajd
# header 'authorization: OAuth oauth_consumer_key="CONSUMER_API_KEY",
# oauth_nonce="OAUTH_NONCE", oauth_signature="OAUTH_SIGNATURE",
# oauth_signature_method="HMAC-SHA1",
# oauth_timestamp="OAUTH_TIMESTAMP",
# oauth_token="ACCESS_TOKEN", oauth_version="1.0"
data = requests.get('https://api.twitter.com/2/users/by/username/bermudesviana', headers=headers)
data = data.json()
#print(data)
#print(data['data']['id'])
seguindo = requests.get(f"https://api.twitter.com/2/users/{data['data']['id']}/following", headers=headers)
seguindo = seguindo.json()
dataList = seguindo['data']
for index in range(len(dataList)):
for key in dataList[index]:
if key == 'username':
print(dataList[index][key])
'''
A partir do A:
Fila = {
}
graph = {
'A' = {'B', 'C', 'D'},
'B' = {}
'C' = {'G'}
'D' = {'H'}
'G' = {}
'H' = {'J'}
'J' = {}
}
Visitados = {
'A', 'B', 'C', 'D', 'G', 'H', 'J'
}
A partir do J:
Fila = {
'J'
}
graph = {
'H' = {'J'}
'I' = {'J'}
}
Visitados = {
'J',
}
Fazer com que o J seja o mais famoso
seguindo['data']
{
'data':
[
{
'id': '218229279',
'name': 'MTST',
'username': 'mtst'
},
{},
{}
],
'meta': {
'result_count': 100,
'next_token': '2HI1VVQ14O71GZZZ'
}
}
'''