From 4282eac809477da6e4a44af13d2b0ffa85492701 Mon Sep 17 00:00:00 2001 From: caibotmi Date: Sun, 5 Apr 2026 16:33:29 +0800 Subject: [PATCH] fix: extract author_username from tags in postuserinfo div --- crawlers/crawl_today.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crawlers/crawl_today.py b/crawlers/crawl_today.py index 508f752..0ab3da6 100644 --- a/crawlers/crawl_today.py +++ b/crawlers/crawl_today.py @@ -75,7 +75,7 @@ class YichensTodaySpider(PaginationSpider): soup = BeautifulSoup(html, "html.parser") page_text = soup.get_text() - match = re.search(r"ID=(\d+)", url) + match = re.search(r"\&ID=(\d+)", url) post_id = match.group(1) if match else None title = None @@ -135,6 +135,18 @@ class YichensTodaySpider(PaginationSpider): elif "马钞" in title: category = "马钞" + # 从 postuserinfo div 的 标签提取用户名(跳过电话号码) + if not author: + userinfos = soup.find_all('div', class_='postuserinfo') + for ui in userinfos: + for b in ui.find_all('b'): + text = b.get_text(strip=True) + if text and not re.match(r'^1\d{10}$', text) and len(text) > 1: + author = text + break + if author: + break + return { "post_id": post_id, "title": title,