做内容合作研究时,一份有来源、能核对的作者名单,比大量未经筛选的姓名更有用。先确定主题与资料使用范围,再整理公开职业信息;不要收集与合作无关的私人资料。

作者清单:本地整理与核对,正文内容要点图

先准备有来源的表格

下面示例只处理已获授权的本地 CSV,不抓取网站、不访问个人账号。输入文件 authors.csv 包含 name、profile_url、topic 三列,分别记录姓名、公开职业资料地址和相关主题。

清理链接并去重

代码去掉链接片段,保留路径和查询参数。去重以处理后的完整链接为准,不通过名字合并不同的人。输出采用新建模式,文件已存在时停止,避免覆盖之前的记录。

import csv
from urllib.parse import urlsplit, urlunsplit

def cell(value):
    # Prevent spreadsheet formula interpretation.
    return "'" + value if value.lstrip().startswith(("=", "+", "-", "@")) else value

seen, rows = set(), []
with open("authors.csv", encoding="utf-8-sig", newline="") as f:
    reader = csv.DictReader(f)
    required = {"name", "profile_url", "topic"}
    if not required.issubset(reader.fieldnames or []):
        raise ValueError("Missing required columns")
    for row in reader:
        name = (row.get("name") or "").strip()
        raw = (row.get("profile_url") or "").strip()
        try:
            u = urlsplit(raw)
        except ValueError:
            continue
        if not name or u.scheme not in ("http", "https") or not u.netloc:
            continue
        url = urlunsplit((u.scheme, u.netloc, u.path, u.query, ""))
        if url in seen:
            continue
        seen.add(url)
        rows.append([cell(name), cell(url), cell((row.get("topic") or "").strip())])
with open("authors_clean.csv", "x", encoding="utf-8-sig", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["name", "profile_url", "topic"])
    writer.writerows(rows)

清理结束后仍要人工判断

核实资料是否对应本人、是否与当前主题相关、信息是否过期。同一作者可能有多个公开地址,代码不会替你确定身份。后续联系应有真实合作背景,并尊重对方意愿,不能把名单直接用于无差别群发。

这类自动化适合减少整理工作。更多流程可参考SEO 自动化任务选择,让数据来源、处理规则和使用目的始终可追溯。

0.018327s