構造多種請求頭資訊,並隨機抽取資訊

2021-09-28 19:34:50 字數 904 閱讀 8156

構造多個請求頭資訊

使用random隨機抽取資訊

話不多說,直接上**

import random

# 構造請求頭資訊,隨機抽取資訊

agent1 =

'mozilla/5.0 (windows nt 6.1; wow64; rv:6.0) gecko/20100101 firefox/6.0'

agent2 =

agent3 =

agent4 =

'mozilla/4.0 (compatible; msie 7.0; windows nt 6.1; wow64; trident/5.0; slcc2; .net clr 2.0.50727; .net clr ' \

'3.5.30729; .net clr 3.0.30729; media center pc 6.0; infopath.3; .net4.0c; .net4.0e; se 2.x metasr 1.0) '

agent5 =

'mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; wow64; trident/5.0; slcc2; .net clr 2.0.50727; .net clr ' \

'3.5.30729; .net clr 3.0.30729; media center pc 6.0; infopath.3; .net4.0c; .net4.0e) '

list1 =

[agent1, agent2, agent3, agent4, agent5]

agent = random.choice(list1)

# 列印請求頭資訊

print

(agent)

header =

具體使用請看

HTTP請求頭資訊

錯誤 解釋 100 continue 101 witching protocols 200 ok 201 created 202 accepted 203 non authoritative information 204 no content 205 reset content 206 parti...

請求頭資訊介紹

常用請求頭 1.accept 這個頭表示.瀏覽器告訴伺服器所支援的資料型別 2.accept charset 這個頭表示.瀏覽器告訴伺服器它採用的字符集 3.accept encoding 這個頭表示.瀏覽器告訴伺服器他所支援的壓縮格式 4.accept language 這個 頭表示.瀏覽器告訴伺...

HTTP響應頭資訊和請求頭資訊詳解

web效能測試中有乙個web資源分析,web資源是從伺服器入手對web伺服器的效能進行分析。所以了解一下以下資訊是很有必要的哦。一 響應頭資訊 應答頭說明 allow 伺服器支援哪些請求方法 如get post等 content encoding content length 表示內容長度。只有當瀏...