0
httpプロキシ経由でサーバーに接続するためにソケットライブラリを使用したいと思います。出来ますか?ソケットライブラリ(python3)を使用してプロキシ経由でサーバーに接続
例えば(リクエストライブラリーと):
import requests
r = requests.get("http://www.google.com", #but not necessary to http port.
proxies={"http": "http://ipproxy:portproxy"})
-UPDATE-
import urllib.request
pr = "ipproxy:portproxy"
while True:
try:
proxy = urllib.request.ProxyHandler({'http': pr})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)
url = "ftp://ip" # or ssh:// or some other port
data = None
headers = {}
req = urllib.request.Request(url, data, headers)
print ("Request sent")
except:
print ("An error occurred")
あなたが提案したように、私はurllibライブラリをスクリプトに貼り付けましたが、うまくいきません...実際には "ftp://"の代わりに "foo:// "それは正常に送信された場合のように常に"要求送信 "を印刷します.... – Sperly1987