Hi I am trying to make a code that monitors cryptocurrency prices, so I am fetching JSON data from public sources and then processing it. I am using this python code by @Anurag Uniyal:

import urllib.request, json 
with urllib.request.urlopen("https://api.bitcoincharts.com/v1/weighted_prices.json") as url:
    data = json.loads(url.read().decode())

I have a VM setup that routes everything through Tor, so this code, probably using direct HTTP fetch via urllib doesn't go through, it get's blocked.

So I have to execute this python script via Torsocks, like torsocks python3 code.py.

My question is whether this is safe? I am not familiar with torsocks but it seems like it just "hacks" the connection to go through Tor, and it's not a clean way to do it.

Would there be a more elegant and clean way of fetching JSON via Tor, or is this the only way?


If you have VM setup with all network traffic routed through tor then you do not need to run torsocks.


check this for python requests package

pip install -U requests[socks]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.