ubuntu へ tor コマンドをいれる
tor コマンド ubuntu 16.04
で検索し
Ubuntu Server 16.04 LTS/CentOS 7にtorをインストールしてtor経由でcurlやwgetを使用する
を参考にインストール
1 | sudo apt install tor |
でインストール
次に
python から tor のSOCKSポートにアクセスするため
pysocks ライブラリーのインストール
1 | pip3 install pysocks |
次に
Squid プロキシ経由アクセスのように
ローカルの tor の SOCKS ポートをプロキシ接続するようにする
1 | vim proxy.py |
でファイル作成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import requests proxy = { } ip = requests.get(url).text tor_ip = requests.get(url,proxies = proxy).text print ( "current IP is " + ip) print ( "tor IP is " + tor_ip) |
これで
1 | python proxy.py |
を実行すると
グローバルIP
tor を使ったときのIP
が表示される
によれば
tor はプロキシとして
socks5://localhost:9050
を使っているとのこと