Last active
March 17, 2016 10:30
-
-
Save kuraga/c7d733fa9e9c67669c23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import vk_api | |
from threading import Thread | |
import time | |
def do(vk, code): | |
a = time.time() | |
vk.execute(code=code) | |
b = time.time() | |
print('%.1f' % (b-a,)) | |
if __name__ == '__main__': | |
login, password = 'login', 'password' | |
n = 100 | |
vk_session = vk_api.VkApi(login, password) | |
vk_session.authorization() | |
vk = vk_session.get_api() | |
code = """var posts = [];var offset = 0;while (offset < 2500 && offset < 4000){posts = posts + API.wall.get({"owner_id": "-20629724", "count": 100, "offset": offset}).items;offset = offset + 100;};return posts;""" | |
t = [None] * n | |
for i in range(1, n): | |
t[i] = Thread(target=do, args=(vk, code)) | |
t[i].start() | |
time.sleep(.5) | |
for i in range(1, n): | |
t[i].join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment