ifnull
2/15/2014 - 11:36 PM

Using TOR as a proxy for Python on OSX

Using TOR as a proxy for Python on OSX

#!/usr/bin/python
import requests

proxies = {
  "http": "http://127.0.0.1:8118"
}

headers = {
  'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11'
}

r = requests.get("http://www.telize.com/ip", proxies=proxies, headers=headers)

print r.text

Downloads

Install

Follow the applicable install instructions for the downloads.

Configure

sudo vi /usr/local/etc/privoxy/config

Append the following to /usr/local/etc/privoxy/config

forward-socks5   /               127.0.0.1:9150 .

Reload

sudo /Applications/Privoxy/stopPrivoxy.sh
sudo /Applications/Privoxy/startPrivoxy.sh