Skip to content

Instantly share code, notes, and snippets.

@achmel
Created December 2, 2017 08:13
Show Gist options
  • Save achmel/1fe76fb9abf34a8fdd76cbd5910df5dd to your computer and use it in GitHub Desktop.
Save achmel/1fe76fb9abf34a8fdd76cbd5910df5dd to your computer and use it in GitHub Desktop.
VK markov-chains-based posts generator
#!/usr/bin/env python3
# encoding: utf-8
import vk
import markovify
service_token = '{PUT YOUR TOKEN HERE}'
vk_id = '{PUT VK ID HERE}'
session = vk.Session(access_token=service_token)
vk_api = vk.API(session)
posts_json = vk_api.wall.get(domain=vk_id, count=100)
text = ''
for post in posts_json:
if type(post) != int:
text += post['text']
model = markovify.Text(text)
for i in range (9):
print(model.make_sentence())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment