Skip to content

Instantly share code, notes, and snippets.

@jamiebrynes7
Created August 4, 2018 13:46
Show Gist options
  • Save jamiebrynes7/f547991e6cf9e9025cd3b7453c1fc654 to your computer and use it in GitHub Desktop.
Save jamiebrynes7/f547991e6cf9e9025cd3b7453c1fc654 to your computer and use it in GitHub Desktop.
SpatialOS Docs Generator w/ Markov Chain
import markovify
import requests
from bs4 import BeautifulSoup
RELEASES = ["13.0", "12.2", "11.2"]
BASE_URL = "https://docs.improbable.io/reference/{}/releases/release-notes"
release_notes_list = []
for release in RELEASES:
r = requests.get(BASE_URL.format(release))
html = r.text
soup = BeautifulSoup(html, "html.parser")
docs_div = soup.find(id="docPage")
for note in docs_div.find_all("li"):
release_notes_list.append(note.getText())
release_notes = "\n".join(release_notes_list)
text_model = markovify.NewlineText(release_notes)
for i in range(10):
print(text_model.make_sentence(tries=100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment