-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (42 loc) · 1.49 KB
/
main.py
File metadata and controls
50 lines (42 loc) · 1.49 KB
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
import requests
def get_posts(count, url):
token = 'c8a9a3dbc8a9a3dbc8a9a3db82c8d1ac77cc8a9c8a9a3dba81d4f21975d685893981a54'
version = 5.131
posts = []
offset = 0;
while offset < count:
if url.startswith(('club', 'public')):
url = url.replace('club', '-')
url = url.replace('public', '-')
response = requests.get('https://api.vk.com/method/wall.get',
params = {
'access_token': token,
'v': version,
'owner_id': url,
'count': count,
}
)
else:
response = requests.get('https://api.vk.com/method/wall.get',
params = {
'access_token': token,
'v': version,
'domain': url,
'count': count,
}
)
data = response.json()['response']['items']
posts.extend(data)
offset += 100;
return posts
def parse_to_string(posts):
line = ''
for i in range(len(posts)):
try:
line += posts[i]['text']
except:
pass
return line
posts = get_posts(1000, 'bugurt_thread')
s = parse_to_string(posts)
print(s)