fix #5
This commit is contained in:
parent
55d27d0402
commit
bbfab783b5
File diff suppressed because one or more lines are too long
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user