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())
print(data)
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?