[問題] request 如何實現多重代理
大家好
我有個問題想請教一下
就是關於python Request的proxy單層代理已經實現了
現在我想實現多重代理去匿蹤
這是我的code
請問我這樣有算實現嗎??
Proxy List是來自於
http://goo.gl/xhX32M
我是以這個查詢IP的網站做測試
http://dir.twseo.org/ip-check.php
因為如果使用單層代理的話就會顯示你的來源代理位置
下列是單層代理的程式碼
https://goo.gl/80WK6s
他會跟我說我的來源IP位置
然後我再試著使用下列的程式碼
https://goo.gl/0bdm8k
它就不會顯示我的來源IP位置了
這樣是否達到多重IP的效果呢??
.
然後當我需要再實現第三層的proxy代理時
就出現
ConnectionError: ('Connection aborted.', BadStatusLine("''",)
沒有使用Tor網路的關係是因為我要爬取的網站會鎖定境外IP
請問是否有比使用此種方式去多重代理更好的方式呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.227.164.60
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1462301421.A.4A7.html
→
05/04 10:49, , 1F
05/04 10:49, 1F
→
05/04 10:50, , 2F
05/04 10:50, 2F
→
05/04 10:50, , 3F
05/04 10:50, 3F
→
05/04 10:50, , 4F
05/04 10:50, 4F
→
05/04 10:50, , 5F
05/04 10:50, 5F
→
05/04 10:57, , 6F
05/04 10:57, 6F
→
05/04 10:57, , 7F
05/04 10:57, 7F
→
05/04 10:58, , 8F
05/04 10:58, 8F
→
05/04 10:58, , 9F
05/04 10:58, 9F
→
05/04 10:59, , 10F
05/04 10:59, 10F
回覆kenduest:
proxies={
"http":"http://203.66.159.45:3128"
}
proxies2={
"http":"http://122.147.24.103:8080"
}
r=requests.Session()
res=r.get("http://dir.twseo.org/ip-check.php",proxies=proxies)
res2=r.get("http://dir.twseo.org/ip-check.php",proxies=proxies2)
所以依照你的建議修改了 Session的設定
主要思路是先對網站進行第一次跳板
然後再使用同樣的session去get
就可以第二層跳板嗎??
※ 編輯: yf9000555 (61.230.178.141), 05/04/2016 13:43:21
→
05/04 17:24, , 11F
05/04 17:24, 11F
→
05/04 23:40, , 12F
05/04 23:40, 12F
→
05/04 23:41, , 13F
05/04 23:41, 13F
→
05/04 23:52, , 14F
05/04 23:52, 14F
→
05/04 23:53, , 15F
05/04 23:53, 15F
推
05/07 00:13, , 16F
05/07 00:13, 16F
謝謝 grapherd
我後來在
Tor Browser\Browser\TorBrowser\Data\Tor\
這個資料夾位置找到 torrc 這個檔案
然後用記事本開啟後
在最後面加上
StrictExitNodes 1
ExitNodes {TW}
成功跳板回台灣
謝謝
參考網址 :
使用tor指定出口国家的IP (簡體中文)
http://goo.gl/hDVc7Z
維基百科國家代碼表
https://goo.gl/HmTGBv
※ 編輯: yf9000555 (61.230.166.30), 05/09/2016 13:57:49
Python 近期熱門文章
PTT數位生活區 即時熱門文章