Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. TOKEN = "a68cd66fc736ce18468cfbdff7e342fd6a9c35b0cc9a5423d5738d264f10440b3c965b503d1970c435268"
  2. import vk_api
  3. from collections import Counter
  4. vk_session = vk_api.VkApi(token = TOKEN, app_id = 353179116)
  5. vk = vk_session.get_api()
  6.  
  7. texts = []
  8.  
  9. posts = vk.wall.get(domain="mudakoff", count=100)
  10. for post in posts['items']:
  11.   comments = vk.wall.getComments(owner_id=post['owner_id'], post_id=post['id'], count=100)
  12.   for comment in comments['items']:
  13.     if 'text' in comment:
  14.       texts.append(comment['text'])
  15.  
  16. txt = ' '.join(texts)
  17. txt = txt.replace("\n", " ")
  18. txt = txt.replace(",", "").replace(".", "").replace("?", "").replace("!", "").replace("—", "").replace("-", "")
  19. txt = txt.lower()
  20. txt = txt.split()
  21. print(Counter(txt))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement