1. 程式人生 > 其它 >pycharm傳送請求fiddler抓包失敗和警告:InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See

pycharm傳送請求fiddler抓包失敗和警告:InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See

1、fiddler抓包pycharm失敗

原來的程式碼:

r = requests.post(url, data)

此時傳送的請求fiddler抓取不了資料

修改為:

fiddler_proxies = {'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}   # 避免fiddler抓不到請求資料而設定的
r = requests.post(url, data, proxies=fiddler_proxies, verify=False) # verify和proxies均是為了可以正常使用fiddler抓而設

再次嘗試,可以正常抓包,但是有警告:InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See

2、解決警告:InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See

在傳送請求前,新增程式碼,如下:

fiddler_proxies = {'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}   # 避免fiddler抓不到請求資料而設定的
# 取消警告:InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) r = requests.post(url, data, proxies=fiddler_proxies, verify=False) # verify和proxies均是為了可以正常使用fiddler抓而設