Files
nexus/raw/AI/Scrapy + Playwright 抓取TikTok Shop Data.md
2026-04-28 20:03:11 +08:00

1.5 KiB
Raw Blame History

title, source, author, published, created, description, tags
title source author published created description tags
⚠️ 你使用 Docker可能需要在 Dockerfile 里加入以下内容 shenwei
playwright
scrapy

#scrapy #playwright

最推荐:创建虚拟环境 (venv) 并安装 Scrapy + Playwright

进入你的工程目录:


cd ~/Docker/tiktok_shop_scraper

创建 venv


python3 -m venv venv

激活 venv

source venv/bin/activate

(你会看到终端前面出现 (venv)

(venv) root@shenwei-HP-ZBook-01:/home/shenwei/Docker/tiktok_shop_scraper# 

后续再次进入venv

source /home/shenwei/Docker/tiktok_shop_scraper/venv/bin/activate

在venv环境里安装依赖

pip install --upgrade pip 
pip install scrapy scrapy-playwright

安装 Playwright Chromium

playwright install chromium

然后运行你的 spider

scrapy runspider tiktok_shop_spider.py -a shop_url="https://www.tiktok.com/shop/store/xxxx/xxxxxxxxxxxx"

scrapy runspider tiktok_shop_spider.py -a shop_url="https://www.tiktok.com/shop/store/aopuro/7495894041403296077"


⚠️ 你使用 Docker可能需要在 Dockerfile 里加入以下内容

如果你是用 Dockerfile 构建容器,记得加两行:

。/
RUN python3 -m venv /app/venv ENV PATH="/app/venv/bin:$PATH"

🧪 验证 Playwright 是否安装成功

在 venv 中执行:

python -c "from playwright.sync_api import sync_playwright; print('Playwright OK')"