Python JSON fetching via Tor Socks5 proxy

385 Views Asked by At

I am trying to fetch JSON data, via a Python3 script, on Tails. I would like to know that this code is secure and doesn't leak IP or any other stuff. I know that Tails is configured to block any problematic connection, so I would like to know if my code is safe.

import json
import requests

url = 'https://api.bitcoincharts.com/v1/markets.json'
proxy = {'https': "socks5://127.0.0.1:9050"}

with open('datafile','w') as outfile:
  json.dump( (requests.get(url  ,  proxies=proxy  ).json())  ,outfile)

As you can see I am using the requests that has been suggested for proxies. I use socks5 just like the docs suggest, configured for the localhost 9050 port that tor listens to.

I guess if the website would be http then I would have to change the proxy to 'http' as well.

One thing I am not sure about is whether to use the port 9150 or 9050 , the code seems to work on both proxies, but I don't know which one is safer.

Other than these, is my code safe to use on Tails?

0

There are 0 best solutions below