Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thurask
Created May 18, 2019 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thurask/1c3a129685870d619b5439b6c52c91dd to your computer and use it in GitHub Desktop.
Save thurask/1c3a129685870d619b5439b6c52c91dd to your computer and use it in GitHub Desktop.
import bs4
import more_itertools
import requests
OUTDOORURL = "https://www.deichschafblog.de/s4/mods-fuer-outdoor-leben/"
WORKURL = "https://www.deichschafblog.de/s4/mods-fuer-an-die-arbeit/"
TOGETHERURL = "https://www.deichschafblog.de/s4/mods-fuer-zeit-fuer-freunde/"
CITYURL = "https://www.deichschafblog.de/s4/mods-fuer-grossstadtleben/"
VAMPIRESURL = "https://www.deichschafblog.de/s4/mods-fuer-vampire/"
PARENTHOODURL = "https://www.deichschafblog.de/s4/mods-fuer-elternfreuden/"
CATSANDDOGSURL = "https://www.deichschafblog.de/s4/mods-fuer-hunde-katzen/"
LAUNDRYDAYURL = "https://www.deichschafblog.de/s4/mods-fuer-waschtag-accessoires/"
JUNGLEURL = "https://www.deichschafblog.de/s4/mods-fuer-dschungel-abenteuer/"
SEASONSURL = "https://www.deichschafblog.de/s4/mods-fuer-outdoor-leben/"
FOODURL = "https://www.deichschafblog.de/s4/mods-rund-um-mahlzeiten/"
MISCURL = "https://www.deichschafblog.de/s4/sonstige-mods/"
def get_version(sess, inurl):
moddict = {}
req = sess.get(inurl)
soup = bs4.BeautifulSoup(req.text, "html.parser")
tbody = soup.find("tbody")
trows = [child for child in tbody.children if child != "\n"]
for row in trows:
relname = row.find("td", {"class": "column-1"}).text.split("\n")[0]
reldate = row.find("td", {"class": "column-2"}).text.strip()
if "Version" in reldate:
relsplit = [item.strip() for item in reldate.split("\n") if item]
relpairs = more_itertools.grouper(relsplit, 2)
for rel in relpairs:
moddict["{} {}".format(relname, rel[0])] = rel[1]
else:
moddict[relname] = reldate
return moddict
def pretty_printer(title, indict):
print(title.upper())
for key in indict.keys():
print("\t{}: {}".format(key, indict[key]))
def master_printer(session, inurl, title):
modlist = get_version(session, inurl)
pretty_printer(title, modlist)
def main():
session = requests.Session()
master_printer(session, OUTDOORURL, "Outdoor Retreat")
master_printer(session, WORKURL, "Get to Work")
master_printer(session, TOGETHERURL, "Get Together")
master_printer(session, CITYURL, "City Living")
master_printer(session, VAMPIRESURL, "Vampires")
master_printer(session, PARENTHOODURL, "Parenthood")
master_printer(session, CATSANDDOGSURL, "Cats & Dogs")
master_printer(session, LAUNDRYDAYURL, "Laundry Day Stuff")
master_printer(session, JUNGLEURL, "Jungle Adventures")
master_printer(session, SEASONSURL, "Seasons")
master_printer(session, FOODURL, "Food")
master_printer(session, MISCURL, "Misc")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment