先打開ss
根據官方的方式
http://cn.python-requests.org/zh_CN/latest/user/advanced.html#proxies
使用 socks5 應該這樣用
import requests
proxies = {
'http': 'socks5://127.0.0.1:1080',
'https': 'socks5://127.0.0.1:1080'
}
r=requests.get('https://www.google.com', proxies=proxies)
print(r.status_code)
但我發現,這個 requests 用這個方式使用 socks5 協議時會出現奇怪的的錯誤,無法使用。
後面經大佬朋友的測試下,發現居然還可以這樣用
import requests
proxies = {
'http': 'http://127.0.0.1:1080',
'https': 'https://127.0.0.1:1080'
}
r=requests.get('https://www.google.com', proxies=proxies)
print(r.status_code)
居然用 http 協議 就連上了 socks5 協議 的端口?!
好吧,後面瞭解了一下 socks5 協議。好像還真支持這種操作
貌似這種操作被稱爲 直接通訊狀態
參考自 https://baike.baidu.com/item/socks5