当前位置:网站首页>scrapy爬虫框架的使用
scrapy爬虫框架的使用
2022-08-01 09:14:00 【liyan_1013】
首先咱们先下载scrapy包

选择Terminal,创建scrapy项目(scrapy startproject 项目名字)

这时候项目创建好了,我们需要修改settings.py文件
20行,ROBOTSTXT_OBEY = False

把65到67的注释取消(原本它是被注释的)

把40到43的注释取消(原本它是被注释的),并在里面添加请求头,


进入spiders目录创建爬虫文件
scrapy genspider 爬虫文件名 域名

咱们爬取课程名称和学习人数

修改start_urls为所要爬取的地址

全选复制,粘贴
找到要爬取所有信息的父标签,并且父标签是唯一的(可以右键,查看网页源代码,Ctrl+f搜索该标签属性是否只有一个)

通过分析,我们所要爬取的信息在ul的li里面

我们利用Xpath获取所有的li标签

遍历il,定位要爬取的内容


边栏推荐
- pytest interface automation testing framework | skip test classes
- Redis中间件(从搭建到弃坑)
- leetcode-6133: maximum number of groupings
- [Beyond programming] When the fig leaf is lifted, when people begin to accept everything
- Case practice --- Resnet classic convolutional neural network (Mindspore)
- sql server, FULL mode, dbcc shrinkfile(2,1) can not shrink the transaction log, or the original size, why?
- Prime Ring Problem
- leetcode-6133:分组的最大数量
- HoloView -- Tabular Datasets
- 优炫数据库支持Oracle哪几种时间及日期类型
猜你喜欢
随机推荐
GBase 8c中怎么查询数据库配置参数,例如datestyle
Delphi MDI appliction 文档最大化显示、去掉最大化最小化等按钮
Flink SQL - client, how to deal with the source side and to increase the target, the SQL - client including mapping table and the JOB such as
leetcode-6134:找到离给定两个节点最近的节点
Parsing MySQL Databases: "SQL Optimization" vs. "Index Optimization"
leetcode-6134: Find the closest node to the given two nodes
HoloView 在 jyputer lab/notebook 不显示总结
华为深度学习课程第九章——卷积神经网络以及案例实践
杰理AD14N/AD15N---串口中断问题
Shell executes SQL to send emails
navicat mysql 内存占用过高,被强制关闭
SkiaSharp 之 WPF 自绘 五环弹动球(案例版)
网络个各种协议
解析MySQL数据库:“SQL优化”与“索引优化”
JVM内存模型之深究模型特征
MySQL query advanced - from the use of functions to table joins, do you remember?
ACmix 论文精读,并解析其模型结构
灵魂发问:MySQL是如何解决幻读的?
在GBase 8c数据库后台,使用什么样的命令来对gtm、dn节点进行主备切换的操作
TiDB的真实数据库数据是存在kv和还是pd上?

![ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API](/img/b3/0167c22f14b97eb0206696495af7b5.png)






