Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import vk_api
- import time
- start = time.time()
- link_pattern = "https://vk.me/join/"
- token = "123"
- vk = vk_api.VkApi(token=token).get_api()
- repeat = 1
- all_links = []
- links = vk.newsfeed.search(q=link_pattern, count=200)
- for link in links["items"]:
- if link_pattern in link["text"]:
- link = link["text"][link["text"].find(link_pattern):link["text"].find(link_pattern) + 43]
- if link not in all_links and '.' not in link[13:] and len(link.split()) == 1:
- if len(link) >= 44:
- link = link[0:43]
- elif len(link) < 43:
- continue
- all_links.append(link)
- with open("links.txt", "r") as f:
- links_old = list(set(f.read().split()))
- with open("links.txt", "a", encoding="utf-8") as f:
- for link in all_links:
- if link not in links_old:
- f.write(link + "\n")
- end = time.time()
- print(end - start)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement