modify scripts
This commit is contained in:
@ -119,25 +119,34 @@ def parse_actor_list(soup, href):
|
|||||||
for article in articles:
|
for article in articles:
|
||||||
try:
|
try:
|
||||||
# 获取演员详情
|
# 获取演员详情
|
||||||
title_tag = article.find("h3", class_="loop-item__title").find("a")
|
title_tag = article.find("h3", class_="loop-item__title")
|
||||||
title = title_tag.text.strip()
|
title = title_tag.find("a").text.strip() if title_tag and title_tag.find("a") else "N/A"
|
||||||
href = title_tag["href"]
|
href = title_tag.find("a")["href"] if title_tag and title_tag.find("a") else None
|
||||||
|
|
||||||
# 获取评分
|
# 获取评分
|
||||||
rating_tag = article.find("div", class_="loop-item__rating")
|
rating_tag = article.find("div", class_="loop-item__rating")
|
||||||
rating = rating_tag.text.strip() if rating_tag else "N/A"
|
rating = rating_tag.text.strip() if rating_tag else "N/A"
|
||||||
|
|
||||||
# 获取 Rank 和 Votes
|
# 获取 Rank 和 Votes
|
||||||
meta_tags = article.find("div", class_="loop-item__rank").find_all("span")
|
rank_votes_div = article.find("div", class_="loop-item__rank")
|
||||||
rank = meta_tags[0].find("b").text.strip() if meta_tags else "N/A"
|
meta_tags = rank_votes_div.find_all("span") if rank_votes_div else []
|
||||||
votes = meta_tags[1].find("b").text.strip() if len(meta_tags) > 1 else "N/A"
|
|
||||||
|
# 安全获取 rank 和 votes
|
||||||
|
rank = None
|
||||||
|
votes = None
|
||||||
|
if len(meta_tags) >= 1:
|
||||||
|
rank_b = meta_tags[0].find("b")
|
||||||
|
rank = rank_b.text.strip() if rank_b else "N/A"
|
||||||
|
if len(meta_tags) >= 2:
|
||||||
|
votes_b = meta_tags[1].find("b")
|
||||||
|
votes = votes_b.text.strip() if votes_b else "N/A"
|
||||||
|
|
||||||
# 存入列表
|
# 存入列表
|
||||||
actress_list.append({
|
actress_list.append({
|
||||||
"pornstar": title,
|
"pornstar": title,
|
||||||
"rating": utils.parse_numeric(rating),
|
"rating": utils.parse_numeric(rating) if rating != "N/A" else None,
|
||||||
"rank": utils.parse_numeric(rank),
|
"rank": utils.parse_numeric(rank) if rank is not None else None,
|
||||||
"votes": utils.parse_numeric(votes),
|
"votes": utils.parse_numeric(votes) if votes is not None else None,
|
||||||
"href": href
|
"href": href
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user