前回、torをUbuntu/CentOSへインストールし利用できるようにしたので、今回はPythonからtor経由でのアクセスを行うようにする。 色々なやり方はあるようなので、2つほど試してみる。 1. requesocksを使う場合 requestsのforkでsocksを使うことができるパッケージがあるので、これで対応するのが楽そうだ。 事前にpipでインストールをしておく。 sudo pip install -U requests[socks] 後は、以下のように使用してtor経由でアクセスをすると良い。 #!/usr/bin/python # -*- coding: utf-8 -*- import requests get = requests.get('http://httpbin.org/ip', proxies=dict(http='socks5://127.0.0.1:9