Ivan Kudryakov
commited on
Commit
·
323553e
1
Parent(s):
80e5c7b
commit 1
Browse files- .idea/.gitignore +8 -0
- .idea/VKGraph.iml +8 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +95 -1
- requirements.txt +6 -1
.idea/.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
4 |
+
# Editor-based HTTP Client requests
|
5 |
+
/httpRequests/
|
6 |
+
# Datasource local storage ignored files
|
7 |
+
/dataSources/
|
8 |
+
/dataSources.local.xml
|
.idea/VKGraph.iml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/VKGraph.iml" filepath="$PROJECT_DIR$/.idea/VKGraph.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
CHANGED
@@ -1,4 +1,98 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
x = st.slider('Select a value')
|
4 |
-
st.write(x, 'squared is', x * x)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import plotly.graph_objects as go
|
4 |
+
import networkx as nx
|
5 |
+
import time
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
|
8 |
+
access_token = '24001214633baa923e4caf1fba8da62847aa8df94b3b041d40b54186eabd6a16a81962c9bbbd02f52082a'
|
9 |
+
|
10 |
|
11 |
x = st.slider('Select a value')
|
12 |
+
st.write(x, 'squared is', x * x)
|
13 |
+
|
14 |
+
|
15 |
+
api_version = '5.131'
|
16 |
+
my_id = '167196653'
|
17 |
+
read_id = input("Type interested vk id or write \"0\" to use default: ")
|
18 |
+
if read_id != '0':
|
19 |
+
my_id = read_id
|
20 |
+
print("my_id changed", my_id)
|
21 |
+
friend_num = int(input("Type how many friends you want to show or write \"0\" show all: "))
|
22 |
+
|
23 |
+
|
24 |
+
params_for_users_get = {'user_ids': my_id,
|
25 |
+
'access_token': access_token,
|
26 |
+
'v': api_version}
|
27 |
+
|
28 |
+
myFirstAndLastName = requests.get('https://api.vk.com/method/users.get', params=params_for_users_get)
|
29 |
+
#print(myFirstAndLastName.text)
|
30 |
+
|
31 |
+
params_for_friends_get = {'user_id': my_id,
|
32 |
+
'order': 'hints',
|
33 |
+
'fields': 'sex',
|
34 |
+
'access_token': access_token,
|
35 |
+
'v': api_version}
|
36 |
+
|
37 |
+
r = requests.get('https://api.vk.com/method/friends.get', params=params_for_friends_get)
|
38 |
+
if 'error' in r.json() and r.json()['error']['error_code'] == 30:
|
39 |
+
print('This is private profile, sorry')
|
40 |
+
exit()
|
41 |
+
print(r.text)
|
42 |
+
AllMyFriends = r.json()['response']['items']
|
43 |
+
#print(AllMyFriends[0]['id'])
|
44 |
+
#print(AllMyFriends[0]['is_closed'])
|
45 |
+
#print(AllMyFriends)
|
46 |
+
AllMyFriendsWithoutClosed = [i for i in AllMyFriends if 'is_closed' in i and i['is_closed'] == False]
|
47 |
+
if friend_num == 0:
|
48 |
+
friend_num = len(AllMyFriendsWithoutClosed)
|
49 |
+
|
50 |
+
G = nx.Graph()
|
51 |
+
|
52 |
+
|
53 |
+
def GetFriendListById(friend_id):
|
54 |
+
while True:
|
55 |
+
params_for_another_friends_get = {'user_id': friend_id,
|
56 |
+
'order': 'random',
|
57 |
+
'access_token': access_token,
|
58 |
+
'v': api_version}
|
59 |
+
res = requests.get('https://api.vk.com/method/friends.get', params=params_for_another_friends_get)
|
60 |
+
print(res.text)
|
61 |
+
res_json = res.json();
|
62 |
+
if 'error' in res_json:
|
63 |
+
if res_json['error']['error_code'] == 6:
|
64 |
+
time.sleep(0.8)
|
65 |
+
continue
|
66 |
+
if res_json['error']['error_code'] == 30:
|
67 |
+
return [], False
|
68 |
+
return [], False
|
69 |
+
if 'response' in res_json:
|
70 |
+
return res_json['response']['items'], True
|
71 |
+
return [], False
|
72 |
+
|
73 |
+
|
74 |
+
MyFriends = AllMyFriendsWithoutClosed[:friend_num-1]
|
75 |
+
#MyFriends.append(myFirstAndLastName.json()['response'][0])
|
76 |
+
MyFriendsSet = set([i['id'] for i in MyFriends])
|
77 |
+
MyFriendsDict = dict([(i['id'], i) for i in MyFriends])
|
78 |
+
MyFriendsDict[int(my_id)] = myFirstAndLastName.json()['response'][0]
|
79 |
+
#print(MyFriends)
|
80 |
+
#print(G.nodes())
|
81 |
+
for friend_id in MyFriends:
|
82 |
+
friendFriendList, Flag = GetFriendListById(friend_id['id'])
|
83 |
+
if not Flag:
|
84 |
+
continue
|
85 |
+
G.add_edge(friend_id['id'], int(my_id))
|
86 |
+
for friendFriend_id in friendFriendList:
|
87 |
+
if friendFriend_id in MyFriendsSet:
|
88 |
+
G.add_edge(friend_id['id'], friendFriend_id)
|
89 |
+
|
90 |
+
G_nodes_list = list(G.nodes)
|
91 |
+
#print(G_nodes_list)
|
92 |
+
|
93 |
+
pos = nx.spring_layout(G)
|
94 |
+
#print(pos)
|
95 |
+
|
96 |
+
nx.draw_networkx_nodes(G, pos, node_size=50)
|
97 |
+
nx.draw_networkx_edges(G, pos, edge_color='b')
|
98 |
+
plt.show()
|
requirements.txt
CHANGED
@@ -1 +1,6 @@
|
|
1 |
-
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
requests
|
3 |
+
plotly
|
4 |
+
networkx
|
5 |
+
time
|
6 |
+
matplotlib
|