- 19、 Python快速开发分布式搜索引擎Scrapy精讲—cs
- 将bloomfilter(布隆过滤器)集成到scrapy-red
- Python快速开发分布式搜索引擎Scrapy精讲!
- 37、Python快速开发分布式搜索引擎Scrapy精讲—将bl
- 20、 Python快速开发分布式搜索引擎Scrapy精讲—编写
- 18、 Python快速开发分布式搜索引擎Scrapy精讲—Sc
- 26、 Python快速开发分布式搜索引擎Scrapy精讲—通过
- 31、Python快速开发分布式搜索引擎Scrapy精讲—chr
- 39、Python快速开发分布式搜索引擎Scrapy精讲—ela
- 23、 Python快速开发分布式搜索引擎Scrapy精讲—cr
【百度云搜索,搜各种资料:http://www.81ad.cn】
css选择器
1、

2、

3、

::attr()获取元素属性,css选择器
::text获取标签文本
举例:
extract_first('')获取过滤后的数据,返回字符串,有一个默认参数,也就是如果没有数据默认是什么,一般我们设置为空字符串
extract()获取过滤后的数据,返回字符串列表
# -*- coding: utf-8 -*-
import scrapy
class PachSpider(scrapy.Spider):
name = 'pach'
allowed_domains = ['blog.jobbole.com']
start_urls = ['http://blog.jobbole.com/all-posts/']
def parse(self, response):
asd = response.css('.archive-title::text').extract() #这里也可以用extract_first('')获取返回字符串
# print(asd)
for i in asd:
print(i)

【转载自:http://www.leiqiankun.com/?id=62】
网友评论