Commit d13aeedc authored by liyang's avatar liyang

fix:twitter 过滤

parent e66c1079
......@@ -99,27 +99,34 @@ def reptile(browser=None, search_word=""):
title = f"{author}-{datetime.fromtimestamp(int(timestamp))}"
video_list = soup.find_all("video")
image_list = soup.find_all("img")
# lth = len(ignore_list)
if len(video_list) > 0:
# 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)
for item in video_list:
# 把video替换成img标签
# 创建 <img> 标签
img_tag = soup.new_tag('img')
img_tag["src"] = item["poster"]
item.replaceWith(img_tag)
# 确保列表中至少有两个 <div> 子元素
if len(div_elements) >= 2:
# 获取第二个 <div> 元素,并将其从父级元素中移除
div_to_remove = div_elements[1]
div_to_remove.extract()
# if len(div_elements) >= 2:
# # 获取第二个 <div> 元素,并将其从父级元素中移除
# for item in div_elements:
# if hasattr(item,"aria-labelledby"):
# item.extract()
# 删除
# div.decompose()
# 创建video标签占位
custom_video = soup.new_tag("video")
custom_video["src"] = ""
soup.find("div").append(custom_video)
# custom_video = soup.new_tag("video")
# custom_video["src"] = ""
# soup.find("div").append(custom_video)
else:
# print("")
error = ""
image_list = soup.find_all("img")
picture_url = []
if len(image_list) > 0:
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