Created
December 2, 2017 08:13
-
-
Save achmel/1fe76fb9abf34a8fdd76cbd5910df5dd to your computer and use it in GitHub Desktop.
VK markov-chains-based posts generator
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
#!/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