Fix a bunch of bot code and checkin systemd files

This commit is contained in:
RussellChamp committed 2018-11-01 11:05:52 -04:00
1 parent 6770c70068
commit 2a2ed1e064
26 files changed
+222 -137

No files matched your search

+5 -4
View File
@@ -1,3 +1,4 @@
#!/usr/bin/python3
import urllib
from bs4 import BeautifulSoup
import random
@@ -6,11 +7,11 @@ import random
def define(word):
defs = []
url = "http://www.merriam-webster.com/dictionary/{}".format(word)
soup = BeautifulSoup(urllib.urlopen(url).read(), "html.parser")
soup = BeautifulSoup(urllib.request.urlopen(url).read(), "html.parser")
head = soup.find("div", id="headword")
if head:
for p in head.find_all("p"):
defs.append(p.text.encode("ascii", "ignore"))
defs.append(p.text)
return defs
@@ -22,11 +23,11 @@ def defWord(word, short=True):
url = "http://www.dictionaryapi.com/api/v1/references/collegiate/xml/{}?key={}".format(
word, key
)
soup = BeautifulSoup(urllib.urlopen(url).read(), "html5lib")
soup = BeautifulSoup(urllib.request.urlopen(url).read(), "html5lib")
entry = soup.find("entry")
if entry:
for d in entry.find_all("dt"):
defs.append(d.text.encode("ascii", "ignore"))
defs.append(d.text)
if short:
return " ".join(defs)
else: