Commit d13aeedc authored by liyang's avatar liyang

fix:twitter 过滤

parent e66c1079
...@@ -99,27 +99,34 @@ def reptile(browser=None, search_word=""): ...@@ -99,27 +99,34 @@ def reptile(browser=None, search_word=""):
title = f"{author}-{datetime.fromtimestamp(int(timestamp))}" title = f"{author}-{datetime.fromtimestamp(int(timestamp))}"
video_list = soup.find_all("video") video_list = soup.find_all("video")
image_list = soup.find_all("img")
# lth = len(ignore_list) # lth = len(ignore_list)
if len(video_list) > 0: if len(video_list) > 0:
# for key,element in enumerate(video_list): # for key,element in enumerate(video_list):
# div_elements = soup.find("div").findChildren("div", recursive=False)
div_elements = soup.find("div").findChildren("div", recursive=False)
# div_tags = soup.find_all("div", recursive=False) # div_tags = soup.find_all("div", recursive=False)
for item in video_list:
# 把video替换成img标签
# 创建 <img> 标签
img_tag = soup.new_tag('img')
img_tag["src"] = item["poster"]
item.replaceWith(img_tag)
# 确保列表中至少有两个 <div> 子元素 # 确保列表中至少有两个 <div> 子元素
if len(div_elements) >= 2: # if len(div_elements) >= 2:
# 获取第二个 <div> 元素,并将其从父级元素中移除 # # 获取第二个 <div> 元素,并将其从父级元素中移除
div_to_remove = div_elements[1] # for item in div_elements:
div_to_remove.extract() # if hasattr(item,"aria-labelledby"):
# item.extract()
# 删除 # 删除
# div.decompose() # div.decompose()
# 创建video标签占位 # 创建video标签占位
custom_video = soup.new_tag("video") # custom_video = soup.new_tag("video")
custom_video["src"] = "" # custom_video["src"] = ""
soup.find("div").append(custom_video) # soup.find("div").append(custom_video)
else: else:
# print("") # print("")
error = "" error = ""
image_list = soup.find_all("img")
picture_url = [] picture_url = []
if len(image_list) > 0: if len(image_list) > 0:
for key, element in enumerate(image_list): for key, element in enumerate(image_list):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment