内的
标签中
"""
html = _fetch(url)
# 提取标题
title_match = re.search(r'
([^<]+)', html)
title = title_match.group(1).strip() if title_match else ""
# 提取发布日期
date_match = re.search(r"发布时间[::]\s*([\d年\-./]+)", html)
date = date_match.group(1).strip() if date_match else ""
# 提取正文
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": date,
"url": url,
"content": "\n\n".join(content_paras),
}
def scio_press_list():
"""
国新办 - 新闻发布会文字实录
注意: scio.gov.cn 有反爬保护,此处使用 PBC 站点作为镜像
PBC 的 "国新办举行新闻发布会" 系列完整保留了国新办原文
URL: https://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html
"""
html = _fetch(
"https://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html"
)
items = re.findall(
r'
]*href="(/goutongjiaoliu/[^"]+)"[^>]*>([^<]{10,})',
html,
)
results = []
seen = set()
for href, title in items:
title = title.strip()
if title and href not in seen and "国新办" in title:
seen.add(href)
results.append(
{
"title": title,
"date": "",
"url": "https://www.pbc.gov.cn" + href,
}
)
return results
def xinhuanet_list():
"""
新华社 - 受权发布/时政
注意: 使用 www.news.cn(新域名),旧 xinhuanet.com 只有 2021 年旧数据
URL: https://www.news.cn/
结构: 服务端渲染,标题在
文章链接格式: /{channel}/{YYYYMMDD}/{32-hex}/c.html
"""
html = _fetch("https://www.news.cn/")
pattern = r'
]*>
]*href=[\'"](https?://www\.news\.cn/[^"\']+/20\d{6}/[a-f0-9]{32}/c\.html)[\'"][^>]*>([^<]+)'
items = re.findall(pattern, html)
results = []
seen = set()
for url, title in items:
title = title.strip()
if title and url not in seen:
seen.add(url)
date_match = re.search(r"/(20\d{6})/", url)
date = ""
if date_match:
d = date_match.group(1)
date = f"{d[:4]}-{d[4:6]}-{d[6:8]}"
results.append({"title": title, "date": date, "url": url})
return results
def xinhuanet_article(url):
"""
新华社 - 文章正文
标题:
...
正文:
内的
标签
"""
html = _fetch(url)
title_match = re.search(r'
]*>.*?]*>([^<]+)', html, re.DOTALL)
if not title_match:
title_match = re.search(r'([^<]+)', html)
title = title_match.group(1).strip() if title_match else ""
# 提取正文
content_match = re.search(r'id="detailContent"[^>]*>(.*?)
\s*(?:
标题
"""
html = _fetch(
"https://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html"
)
items = re.findall(
r'
]*href="(/goutongjiaoliu/[^"]+)"[^>]*>([^<]{10,})',
html,
)
results = []
seen = set()
for href, title in items:
title = title.strip()
if title and href not in seen and len(title) > 5:
seen.add(href)
# 从 URL 提取日期 (格式: 2026071518015458230)
date_match = re.search(r"/(20\d{6})\d{11}/", href)
date = ""
if date_match:
d = date_match.group(1)
date = f"{d[:4]}-{d[4:6]}-{d[6:8]}"
results.append(
{
"title": title,
"date": date,
"url": "https://www.pbc.gov.cn" + href,
}
)
return results
def pbc_article(url):
"""中国人民银行 - 文章正文(正文在
标签中)"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
def mof_list():
"""
财政部 - 财政新闻/政策
URL: https://www.mof.gov.cn/zhengwuxinxi/caizhengxinwen/
结构: 服务端渲染,
标题 + 日期
"""
html = _fetch("https://www.mof.gov.cn/zhengwuxinxi/caizhengxinwen/")
items = re.findall(
r'href="([^"]*t2026[^"]+\.htm)"[^>]*>\s*([^<]{10,80})\s*\s*(?:.*?(\d{4}[-/]\d{2}[-/]\d{2}))?',
html,
re.DOTALL,
)
results = []
seen = set()
for url, title, date in items:
title = title.strip()
if title and url not in seen:
seen.add(url)
if url.startswith("./") or url.startswith("t20"):
url = "https://www.mof.gov.cn/zhengwuxinxi/caizhengxinwen/" + url.replace("./", "")
results.append({"title": title, "date": date or "", "url": url})
return results
def mof_article(url):
"""财政部 - 文章正文"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
date_match = re.search(r"发布日期[::]\s*([\d年\-./]+)", html)
date = date_match.group(1).strip() if date_match else ""
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": date,
"url": url,
"content": "\n\n".join(content_paras),
}
def ndrc_list(page=1):
"""
发改委 - 产业政策/规划
URL: https://www.ndrc.gov.cn/xxgk/
结构: 服务端渲染,
分页: index_{page-1}.html
"""
if page == 1:
list_url = "https://www.ndrc.gov.cn/xxgk/"
else:
list_url = f"https://www.ndrc.gov.cn/xxgk/index_{page - 1}.html"
html = _fetch(list_url)
items = re.findall(
r'
]*href="([^"]+)"[^>]*>\s*([^<]{10,})\s*\s*
\s*([\d/]+)\s*',
html,
)
results = []
for url, title, date in items:
title = title.strip()
if not title:
continue
if url.startswith("./"):
url = "https://www.ndrc.gov.cn" + url[1:]
results.append({"title": title, "date": date, "url": url})
return results
def ndrc_article(url):
"""发改委 - 文章正文(正文在 div.TRS_Editor 内)"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
editor_match = re.search(r'class="TRS_Editor"[^>]*>(.*?)
\s*<', html, re.DOTALL)
if editor_match:
content_paras = _extract_paragraphs(editor_match.group(1))
else:
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
def csrc_list(page=1):
"""
证监会 - 主席讲话/政策公告
URL: https://www.csrc.gov.cn/csrc/c100028/
结构: HTML 页面(API 返回空结果,需用 common/searchList 获取 HTML)
HTML URL: /common/searchList/{channelid}?_isAgg=true&_isJson=true&_pageSize=18&_template=index&page={N}
"""
channel_id = "c100028"
url = f"https://www.csrc.gov.cn/common/searchList/{channel_id}?_isAgg=true&_isJson=true&_pageSize=18&_template=index&page={page}"
html = _fetch(url)
items = re.findall(
r'
]*href="(/csrc/c100028/c\d+/content\.shtml)"[^>]*>([^<]{10,})',
html,
)
results = []
seen = set()
for path, title in items:
title = title.strip()
if title and path not in seen:
seen.add(path)
results.append(
{
"title": title,
"date": "",
"url": "https://www.csrc.gov.cn" + path,
}
)
return results
def csrc_article(url):
"""证监会 - 文章正文"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
def mofcom_list():
"""
商务部 - 外贸/消费政策
URL: https://www.mofcom.gov.cn/
结构: 政策列表页使用 JSON API
API: /api-gateway/jpaas-publish-server/front/page/build/unit
"""
html = _fetch("https://www.mofcom.gov.cn/")
# 首页新闻是 SSR
items = re.findall(
r'
]*href="([^"]+)"[^>]*>\s*([^<]{10,80})\s*',
html,
)
results = []
seen = set()
for url, title in items:
title = title.strip()
if title and url not in seen and len(title) > 8:
seen.add(url)
if url.startswith("/"):
url = "https://www.mofcom.gov.cn" + url
results.append({"title": title, "date": "", "url": url})
return results
def mofcom_article(url):
"""商务部 - 文章正文(正文在 div.wms-con 内)"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
content_match = re.search(r'class="wms-con"[^>]*>(.*?)
\s*<', html, re.DOTALL)
if content_match:
content_paras = _extract_paragraphs(content_match.group(1))
else:
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
# ============================================================
# 优先级 3: 权威媒体转载
# ============================================================
def people_editorial_list():
"""
人民日报 - 社论/观点
URL: http://opinion.people.com.cn/GB/8213/49160/index.html
结构: 主页面有多个子栏目,每个子栏目页面有
文章列表
文章URL格式: /n1/2026/0623/c223228-40745676.html (相对) 或完整URL
"""
base = "http://opinion.people.com.cn/GB/8213/49160/"
html = _fetch(base + "index.html")
# 获取所有子栏目链接(完整URL)
sub_urls = re.findall(r'href="(http://opinion\.people\.com\.cn/GB/8213/49160/\d+/index\.html)"', html)
sub_urls = list(dict.fromkeys(sub_urls))
results = []
seen = set()
for sub in sub_urls:
try:
sub_html = _fetch(sub)
# 解析 项目(注意:人民网的链接使用单引号 href='...')
lis = re.findall(r"]*>(.*?)", sub_html, re.DOTALL)
for li in lis:
# 匹配单引号或双引号的 href
m = re.search(r"href=['\"](/n1/\d{4}/\d{4}/c[\d-]+\.html)['\"][^>]*>([^<]{10,})", li)
if m:
url_path, title = m.groups()
title = title.strip()
url = "http://opinion.people.com.cn" + url_path
if title and url not in seen:
seen.add(url)
date_match = re.search(r"/n1/(20\d{2})/(\d{4})/", url)
date = ""
if date_match:
year, md = date_match.groups()
date = f"{year}-{md[:2]}-{md[2:]}"
results.append({"title": title, "date": date, "url": url})
except Exception:
continue
return results
def people_article(url):
"""人民日报 - 文章正文(正文在
标签中,class=rm_txt_zw 的容器内)"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
# 正文在 p 标签中
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
def cctv_list(page=1):
"""
央视新闻 - 新闻联播文字版
URL: https://news.cctv.com/lbj/
结构: JSONP API
API: https://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/china_{page}.jsonp?callback=china
注意: 需要设置 Referer 头
"""
api_url = f"https://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/china_{page}.jsonp?callback=china"
raw = _fetch(api_url, headers={"Referer": "https://news.cctv.com/"})
# 解析 JSONP: china({...})
json_match = re.search(r"[^(]+\((\{.*\})\)", raw, re.DOTALL)
if not json_match:
return []
try:
data = json.loads(json_match.group(1))
except json.JSONDecodeError:
return []
items = data.get("data", {}).get("list", []) if isinstance(data.get("data"), dict) else []
results = []
for item in items:
title = item.get("title", "").strip()
url = item.get("url", item.get("link", ""))
date = item.get("focus_date", item.get("date", ""))
if title and url:
results.append(
{
"title": title,
"date": str(date)[:10],
"url": url,
}
)
return results
def cctv_article(url):
"""央视新闻 - 文章正文(正文在 div.content_area 内)"""
html = _fetch(url)
title_match = re.search(r"
([^<]+)", html)
title = title_match.group(1).strip() if title_match else ""
content_match = re.search(r'class="content_area"[^>]*>(.*?)
\s*<', html, re.DOTALL)
if content_match:
content_paras = _extract_paragraphs(content_match.group(1))
else:
content_paras = _extract_paragraphs(html)
return {
"title": title,
"date": "",
"url": url,
"content": "\n\n".join(content_paras),
}
def ce_list():
"""
经济日报 - 部委政策解读
URL: http://www.ce.cn/
结构: 服务端渲染,文章链接格式: /xwzx/gnsz/gdxw/202607/t20260721_xxxxxxx.shtml
政策相关文章在 /gnsz/ (国内时政) 和 /xwzx/ (新闻) 栏目下
"""
html = _fetch("http://www.ce.cn/")
items = re.findall(
r'