mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
Fix a bunch of bot code and checkin systemd files
This commit is contained in:
1 parent
6770c70068
commit
2a2ed1e064
26 files changed
+222
-137
No files matched your search
+3
-2
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import urllib
|
||||
from bs4 import BeautifulSoup
|
||||
import random
|
||||
@@ -6,7 +7,7 @@ import re
|
||||
|
||||
def tumble(url):
|
||||
# Find the max pages
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), "html.parser")
|
||||
soup = BeautifulSoup(urllib.request.urlopen(url).read(), "html.parser")
|
||||
pages = soup.findAll("span", "page-numbers")[0].text.split("/")[
|
||||
1
|
||||
] # this could totally fail several ways
|
||||
@@ -17,7 +18,7 @@ def tumble(url):
|
||||
|
||||
# Parse a page
|
||||
soup = BeautifulSoup(
|
||||
urllib.urlopen(url + "/page/" + str(page)).read(), "html.parser"
|
||||
urllib.request.urlopen(url + "/page/" + str(page)).read(), "html.parser"
|
||||
)
|
||||
article = random.choice(soup.findAll("article"))
|
||||
quote = article.find("blockquote").text.replace("\n", "")
|
||||
|
||||
Reference in new issue
Block a user