Selector中的css选择器

返回的数据

返回response的方法:
一般是利用requests的get方法
得到放回的response有如下几个属性:
Status_code: http放回的状态码200表示成功,404表示未找到
Text:相应内容的字符串形式。url对应的页面内容
Encoding:从HTTP header中猜测相应的内容编码方式
Headers:http相应内容的头部内容

**

css选择器的实例

**
quote.css (’ .text ’)
[<Selector xpath=”descendant-or-self: :[@class and contains(concat(’’, normalize space(@class),”),
’ text ’ )] ” data=’<span class=’<span class=”text ” itemprop=”text ” 〉“The ’ 〉 ]
理解:如果只选择class为text 的话那么css选择器会返回第一个class为text 的标签,并返回所有的属性

quote . css (’. text: : text’ )
[<Selector xpath="descendant-or-self:: *[@class and contains(concat(’’, normalize-space(@class), '’), ’ text’ ) ]/text() " data=’“The world as we have created it is a pr ’>]
理解:返回标签的性质和对应的正文

quote . css ( ’ .text ’) . extract()
[’<span class=”t ext " itemprop=“text”>“The world as we have created it is a process our our thinking. It cannot be changed without changing our thinking /span > ’ )
理解:返回标签的所有属性和正文

quote. css (’. text: : text ’) . extract()
[ ’”The world as we have created it is a process of our thinking. It cannot be changed without changing our thinking. ”’]
理解:返回一个列表这个列表含有正文内容

quote . css ( ’. text: : text ’) . extract_ first()
”The world as we have created it is a process of our thinking . It cannot be changed without changing our thin
理解:返回列表的第一个内容

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值