在使用Scrapy框架之前,我们必须先了解它是如何筛选数据的,
Scrapy提取数据有自己的一套机制,被称作选择器(selectors),通过特定的Xpath或者CSS表达式来选择HTML文件的某个部分 Xpath是专门在XML文件中选择节点的语言,也可以用在HTML上。 CSS是一门将HTML文档样式化语言,选择器由它定义,并与特定的HTML元素的样式相关联。而且这些选择器构造于‘lxml’之上,这就意味着Scrapy框架下的数据筛选有着很高的效率。
Scrapy爬虫支持多种信息提取的方法:
下面我们来介绍Xpath选择器和CSS选择器的使用:
好了,以上就是对Scrapy 选择器的介绍以及简单的使用,后面我会慢慢介绍Scrapy框架的具体使用。。。