一、环境准备
1. 安装 Python
官网下载并安装 Python 3.8+(推荐 3.10)
验证安装:终端运行python --version
2. 安装依赖库
pip install scrapy selenium beautifulsoup4 requests numpy pandas
3. 安装 AI 相关库
pip install transformers torch scikit-learn
4. 安装浏览器驱动(用于 Selenium)
Chrome 驱动:下载与本地 Chrome 版本匹配的 ChromeDriver
将驱动文件放入系统 PATH 或项目目录中
二、基础爬虫框架(Scrapy)
1. 创建 Scrapy 项目
scrapy startproject smart_crawlercd smart_crawler
2. 定义爬虫(示例:爬取新闻标题)
编辑spiders/news_spider.py:
领取专属 10元无门槛券
私享最新 技术干货