This commit is contained in:
phillychi3 2024-02-22 18:55:21 +08:00
parent 55d27d0402
commit bbfab783b5
3 changed files with 197 additions and 195 deletions

File diff suppressed because one or more lines are too long

View File

@ -25,8 +25,9 @@ def wtfcloudflare(url, method="get", useragent=None, cookie=None, data=None):
def get_tags(): def get_tags():
with open('set.yaml', 'r') as f: with open('set.yaml', 'r') as f:
cookie = yaml.load(f, Loader=yaml.CLoader)["cookid"] data = yaml.load(f, Loader=yaml.CLoader)
useragent = yaml.load(f, Loader=yaml.CLoader)["useragent"] cookie = data["cookid"]
useragent = data["useragent"]
if cookie == "": if cookie == "":
print("Please edit set.yaml") print("Please edit set.yaml")
exit() exit()
@ -37,7 +38,6 @@ def get_tags():
data = wtfcloudflare(f"{URL}?page={now}", data = wtfcloudflare(f"{URL}?page={now}",
useragent=useragent, cookie=cookie) useragent=useragent, cookie=cookie)
soup = BeautifulSoup(data.text, 'html.parser') soup = BeautifulSoup(data.text, 'html.parser')
print(data.text)
tags = soup.find_all("a", class_='tag') tags = soup.find_all("a", class_='tag')
if tags == []: if tags == []:
break break
@ -49,12 +49,14 @@ def get_tags():
tagnumber.append(fixnum) tagnumber.append(fixnum)
for i in enumerate(tagnumber): for i in enumerate(tagnumber):
tagjson[i[1]] = tagnames[i[0]] tagjson[i[1]] = tagnames[i[0]]
print(f"page {now} done")
now += 1 now += 1
if tagjson == {}: if tagjson == {}:
print("something wrong with your cookie or useragent") print("something wrong with your cookie or useragent")
exit() exit()
with open('tag.json', 'w') as f: with open('tag.json', 'w') as f:
json.dump(tagjson, f) json.dump(tagjson, f)
print("tag.json saved")
return return