日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python 爬虫 ~ 查看收发包的情况

發(fā)布時(shí)間:2025/3/15 python 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 爬虫 ~ 查看收发包的情况 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

DebugLog

  可以用來查看收發(fā)包的情況,比較有意思,現(xiàn)特意記錄下來:

Sample:

import urllib2 httpHandler = urllib2.HTTPHandler(debuglevel=1) httpsHandler = urllib2.HTTPSHandler(debuglevel=1) opener = urllib2.build_opener(httpHandler, httpsHandler) urllib2.install_opener(opener) response = urllib2.urlopen('http://www.baidu.com')

運(yùn)行結(jié)果:

send: 'GET http://www.baidu.com HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: www.baidu.com\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n' reply: 'HTTP/1.1 200 \r\n' header: Content-Length: 111470 header: Bdqid: 0xac52fd1000001301 header: X-Powered-By: HPHP header: Set-Cookie: BAIDUID=C79A798AE88AE217892800990B29F9AF:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com header: Set-Cookie: BIDUPSID=C79A798AE88AE217892800990B29F9AF; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com header: Set-Cookie: PSTM=1506586983; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com header: Set-Cookie: BDSVRTM=0; path=/ header: Set-Cookie: BD_HOME=0; path=/ header: Set-Cookie: H_PS_PSSID=1442_21084_17001_22072; path=/; domain=.baidu.com header: Expires: Thu, 28 Sep 2017 08:22:20 GMT header: Bduserid: 0 header: Server: BWS/1.1 header: Cxy_All: baidu+93815e78c13d58fab2103ab02b94c0d4 header: Date: Thu, 28 Sep 2017 08:23:03 GMT header: P3P: CP=" OTI DSP COR IVA OUR IND COM " header: Content-Type: text/html; charset=utf-8 header: Bdpagetype: 1 header: X-Ua-Compatible: IE=Edge,chrome=1

??

References:

  Python爬蟲入門(4):Urllib庫的高級(jí)用法

?

轉(zhuǎn)載于:https://www.cnblogs.com/Hi-blog/p/7607299.html

總結(jié)

以上是生活随笔為你收集整理的python 爬虫 ~ 查看收发包的情况的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。