Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
network-assets-reptile
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
network-assets-reptile
Commits
d13aeedc
Commit
d13aeedc
authored
Jul 28, 2023
by
liyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:twitter 过滤
parent
e66c1079
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
pc_twitter.py
pc_twitter.py
+17
-10
No files found.
pc_twitter.py
View file @
d13aeedc
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment