import re,requests from bs4 import BeautifulSoup maxhours = 45 with open("tagset.html","r") as tagset: tagsoup = BeautifulSoup(tagset,"html.parser") fandoms = tagsoup.find_all("li",class_="fandom") vns = [] for fandom in fandoms: title = fandom.find("h4") if "Visual Novel" in title.text: thetitle = re.sub(" \(.*Visual Novel.*\)\n.*\n.*","",re.sub(".* \| ","",title.text.strip())) vns.append(thetitle) final = [] for vn in vns: x = requests.post("https://api.vndb.org/kana/vn",json={"filters":["and",["lang","=","en"],["search","=",vn],["olang","=","ja"],["or",["platform","=","ps4"],["platform","=","ps5"],["platform","=","swi"]]],"fields":"title, length_minutes, id"}) try: for result in x.json()["results"]: if result["length_minutes"] < (maxhours * 60): final.append(result["title"] + ": https://vndb.org/" + result["id"] + " (" + vn + ")") except requests.exceptions.JSONDecodeError: pass final = sorted(list(dict.fromkeys(final))) for vn in final: print(vn)