Python module that allows Tor to be used for sockets and HTTP requests
To install basla, clone the repository content and run the following command:
$ python3 setup.py install
If you do not have Tor yet (not Tor browser!), follow the official guide to install it, or download the expert bundle from the official website.
NOTE: If you download the expert bundle manually, you will have to link the path to the Tor binary when using basla
import basla
tor = basla.Tor('/path/to/tor')
Either way, you can just leave it blank.
To use basla you have to bind it to the socket
library:
import basla
import socket
tor = basla.Tor()
tor.bind(socket)
Any connection made through the socket library will be proxied through Tor from now on.
It is enough to make it work for requests
, urllib
, httpx
, etc.
You can also use the proxy manually, without binding:
import basla
import requests
tor = basla.Tor()
session = requests.session()
session.proxies = {
'https': tor.get_formatted_proxy()
}
For full examples, please take a look at the examples folder.