淘宝详情sku爬取

OLIN 9c03213442 first commit 1 month ago
.idea 9c03213442 first commit 1 month ago
commons 9c03213442 first commit 1 month ago
spiders 9c03213442 first commit 1 month ago
README.md 9c03213442 first commit 1 month ago
detail.py 9c03213442 first commit 1 month ago

README.md

淘宝商品详情采集

淘宝药品/商品数据采集系统,支持列表搜索和详情页 SKU 级抓取。

依赖

  • Python 3.8+
  • DrissionPage(浏览器自动化)
  • curl_cffi(API 请求)
  • lxml
  • MySQL

    pip install DrissionPage curl_cffi lxml pymysql
    

需要本地安装 Chrome 浏览器,路径默认 C:\Program Files\Google\Chrome\Application\chrome.exe

detail.py 说明

retrieve_scrape_data 表读取带 + 的商品(一条链接含多个 SKU),打开详情页逐个点击规格,拆解出每条 SKU 的独立记录写入数据库。

流程:

  1. 查询当天 platform_item_id+ 的记录,按 pre_id 去重
  2. 浏览器打开商品链接
  3. 点击 SKU 列表逐一抓取:标题、价格、链接
  4. 删除旧聚合记录,逐条写入拆分后的 SKU 记录

运行:

python detail.py

注意事项

  • detail.py 删写操作在事务内执行,失败自动回滚。