Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- import re
- from pyquery import PyQuery
- import markovify
- url = input("Enter a rhyme")
- r = requests.get('https://www.rhymezone.com/r/ss.cgi?mode=k&loc=rz&q=' + str(url))
- data = r.text
- soup = BeautifulSoup(data, "html.parser")
- rows = soup.find_all('td', string=re.compile(url))
- rhymeList = soup.find_all('blockquote')
- for a in soup("a"):
- a.decompose()
- with open("speare" + str(url) + "rhymes.txt", "w") as file:
- file.write(str(soup.text))
- def poetry():
- with open(r"C:\Users\Ian\.PyCharm2019.1\config\scratches\speareTestrhymes.txt") as f:
- text = f.read()
- lineIncrease = 1
- text_model = markovify.NewlineText(text)
- while lineIncrease <= 12:
- lineIncrease += 1
- print(text_model.make_sentence(tries=10000, state_size=25, max_overlap_ratio=45))
- poetry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement