예제 #1
0
from vkstreaming import Streaming
import vkstreaming

response = vkstreaming.getServerUrl('3af6043f3af6043f3af6043f783aa93cb333af63af6043f6301786bc51f61b908819df3')
api = Streaming(response["endpoint"], response["key"])

api.del_all_rules()
for line in open('/Users/martikvm/PycharmProjects/DoubleSearch/popular_words_100_1.txt'):
    api.add_rules(line.lower(), line)
# api.add_rules('Сегодня', 'сегодня')

rules = api.get_rules()
for rule in rules:
    print(("{tag:15}:{value}").format(**rule))

@api.stream
def my_func(event):
    print("[{}]: {}".format(event['author']['id'], event['text']))

api.start()
예제 #2
0
파일: pars.py 프로젝트: AndrewRyaguzov/mega
import vk_api
import json
import requests
from vkstreaming import Streaming

app_vkid = 6712606
servise_token = "64da4c8064da4c8064da4c803464bc219e664da64da4c803f6dc6be3497baa33cf902f8"

session = vk_api.VkApi(token=servise_token,
                       api_version="5.85",
                       app_id=app_vkid)
vk = session.get_api()
respone = vk.streaming.getServerUrl()

streamingAPI = Streaming(respone["endpoint"], respone["key"])
streamingAPI.del_all_rules()
rules = streamingAPI.get_rules()
streamingAPI.add_rules("1", "мегафон")


@streamingAPI.stream
def my_func(event):

    event_type = event["event_type"]
    print("event type:: ", event_type)

    if event_type == 'comment' or event_type == 'post':

        author = event['author']
        author_url = author['author_url']
        if author['author_url'][15:17] == "id":