⚙️ 参数设置
⚠️ 使用说明:
1. 复制汽车之家帖子的完整URL
2. 粘贴到上方输入框
3. 点击获取数据按钮
4. 查看或下载采集结果
注意:仅供学习研究使用
📋 采集结果 0

输入帖子URL开始采集...

# -*- coding: utf-8 -*-
import requests
from lxml import etree
from fontTools.ttLib import TTFont

url = "https://club.autohome.com.cn/bbs/thread/帖子ID"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36"
}

# 获取页面源码
res = requests.get(url=url, headers=headers)
res_html = res.text

# 解析数据
html = etree.HTML(res_html)
content_list = html.xpath('//div[@class="tz-paragraph"]//text()')

# 连接文本内容
content_str = "".join(content_list)

# 处理字体反爬
# 1. 下载并保存字体文件
font = TTFont("autohome.ttf")
font.saveXML("fonts.xml")

# 2. 构建编码映射表
uniList = font.getGlyphOrder()
word_list = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', ...]

# 3. 替换加密文字
for i in range(len(uniList)):
    content_str = content_str.replace(uni_list[i], word_list[i])

print(content_str)
本地运行方法:
  1. 安装依赖:pip install requests lxml fonttools
  2. 保存代码为 autohome.py
  3. 运行:python autohome.py
技术要点:
  • 汽车之家使用了字体反爬技术
  • 需要下载并解析TTF字体文件
  • 建立字符编码映射关系
  • 批量替换解密后的文本