Requests庫的7個主要方法

2022-05-02 08:24:11 字數 906 閱讀 7269

方法

說明requests.requests()

構造乙個請求,支撐下面方法的基礎方法

requests.get()

獲取html網頁的主要方法,對應

的get

requests.dead()

獲取html網頁頭資訊的方法,對應

的head

requests.post()

向html網頁提交

post

請求的方法,對應

的post

requests.put()

向html網頁提交

put請求的方法,對應

的put

requests.patch()

向html網頁提交區域性修改方法,對應

的patch

requests.delete()

向html網頁提交局刪除請求,對應

的delete

requests最簡單使用

response物件的屬性

屬性說明

r.status_code

http請求返回狀態,

200表示成功,

404失敗

r.text

http響應內容的字串形式,即

url對應的頁面內容

r.encoding

從http header中猜測的響應內容編碼方法

從內容中分析的響應內容編碼方式(備選編碼方式)

r.content

http響應內容的二進位制形式

Requests庫的7個主要的方法

方法 說明requests.requests 構造乙個請求,支撐以下各方法的基礎方法 requests.get 獲取html網頁的主要方法,對應http的get requests.head 獲取html網頁頭資訊的方法,對應與http的head requests.post 獲取html網頁提交的po...

requests庫的七個主要方法

方法 說明requests.request 構造乙個請求,支撐以下各種方法的基礎方法 requests.get 獲取網頁的主要方法,對應http的get requests.head 獲取網頁頭資訊的方法,對應http的head requests.post 向網頁提交post請求,對應於http的po...

Requests庫主要方法解析

method 請求方式,對應get put post等7種 kwargs 可選項 控制訪問的引數,共13個 1 params 字典或者位元組序列,作為引數增加到url中 import requests kv r requests.request get params kv print r.url 2...