傳回的資料
傳回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
了解:傳回清單的第一個内容