Advertisement
Guest User

Untitled

a guest
May 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests
  3. import re
  4. from pyquery import PyQuery
  5. import markovify
  6.  
  7.  
  8. url = input("Enter a rhyme")
  9.  
  10. r = requests.get('https://www.rhymezone.com/r/ss.cgi?mode=k&loc=rz&q=' + str(url))
  11.  
  12. data = r.text
  13.  
  14. soup = BeautifulSoup(data, "html.parser")
  15.  
  16. rows = soup.find_all('td', string=re.compile(url))
  17. rhymeList = soup.find_all('blockquote')
  18.  
  19. for a in soup("a"):
  20.     a.decompose()
  21.  
  22. with open("speare" + str(url) + "rhymes.txt", "w") as file:
  23.     file.write(str(soup.text))
  24.  
  25. def poetry():
  26.     with open(r"C:\Users\Ian\.PyCharm2019.1\config\scratches\speareTestrhymes.txt") as f:
  27.         text = f.read()
  28.     lineIncrease = 1
  29.     text_model = markovify.NewlineText(text)
  30.     while lineIncrease <= 12:
  31.         lineIncrease += 1
  32.         print(text_model.make_sentence(tries=10000, state_size=25, max_overlap_ratio=45))
  33.  
  34. poetry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement