mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
Add files I forgot
This commit is contained in:
1 parent
5f1bf146c3
commit
772995c0ff
29 files changed
+1807
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python3
|
||||
import requests
|
||||
|
||||
# from lxml.html import fromstring
|
||||
from bs4 import BeautifulSoup
|
||||
import random
|
||||
|
||||
|
||||
def getRhymes(word):
|
||||
words = []
|
||||
url = "http://www.rhymer.com/RhymingDictionaryLast/%s.html" % word
|
||||
soup = BeautifulSoup(requests.get(url).content, "html.parser")
|
||||
|
||||
for t in soup.find_all("table", "table"):
|
||||
words.append(
|
||||
random.choice(
|
||||
[
|
||||
w
|
||||
for w in t.text.split("\n")
|
||||
if w not in [u"", u"\xa0"] and "-" not in w
|
||||
]
|
||||
)
|
||||
)
|
||||
return words
|
||||
|
||||
|
||||
def rhymeZone(word):
|
||||
words = []
|
||||
url = (
|
||||
"http://rhymezone.com/r/rhyme.cgi?Word=%s&typeofrhyme=perfect&org1=syl&org2=l&org3=y"
|
||||
% word
|
||||
)
|
||||
soup = BeautifulSoup(requests.get(url).content, "html.parser")
|
||||
|
||||
for t in soup.find_all("a", "d"):
|
||||
w = t.text.rstrip()
|
||||
if w not in [u"", u"\xa0"] and "?" not in t:
|
||||
words.append(w)
|
||||
random.shuffle(words)
|
||||
return words[0:5]
|
||||
Reference in new issue
Block a user