0

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?

2 Answers 2

1

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

0

check this for python requests package

pip install -U requests[socks]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .