Skip to content

Instantly share code, notes, and snippets.

@GINK03
Last active June 13, 2018 16:11
Show Gist options
  • Save GINK03/f25e5feb988e7f4494679e4cbe7fa16a to your computer and use it in GitHub Desktop.
Save GINK03/f25e5feb988e7f4494679e4cbe7fa16a to your computer and use it in GitHub Desktop.
Tor+Requests

torのインストール

$ sudo apt install tor
$ sudo pip3 install pysocks

requestsで使う

IPがそれぞれ異なる

import requests
# tor経由
r = requests.get('https://api.ipify.org', proxies=dict(http='socks5://localhost:9050', https='socks5://localhost:9050'))
print(r.text)
# -> 94.102.51.78

# そのまま
r = requests.get('https://api.ipify.org')
print(r.text)
# -> 60.116.132.211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment