V
V
vante_scribaxxi2018-04-24 18:22:12
Python
vante_scribaxxi, 2018-04-24 18:22:12

How to connect to TOR in python?

There is a script that, through a free proxy in multi-threaded mode, collects data through accounts on one site.
Because it seems to me that socks alone are not enough for high anonymity, I decided to add tor (socks-> tor-> socks).
Question:
How to work with Tor in python? Can this be done without using an external client? It's just that I often work on different machines and carry programs on a flash drive, i.e. installing Tor every time on a new machine will not be very convenient.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2018-04-24
@dimonchik2013

cm.

A
Alex F, 2018-04-24
@delvin-fil

#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import requests

proxies = {
    'http': 'socks5://localhost:9050',
    'https': 'socks5://localhost:9050'
}

url = 'http://icanhazip.com/'
out = requests.get(url, proxies=proxies).text
out = (out.replace('\n',''))
print (out)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question