Getting things out of the way: I'm building a social network which crosses Mastodon and Secure Scuttlebutt protocols. Scuttlebutt is too data intensive and doesn't allow for online communication. Mastodon is too centralized.
My network assigns an onion address to each user (plan to write my own base later, as 50+ character addresses are extreme). I've got the TOR expert bundle on Windows at the moment.
My current code is:
import requests
session = requests.session()
session.proxies = {"http":"socks5://localhost:9050", "https":"socks5://localhost:9050"}
When I try:
session.get("https://google.com").text
It returns Google's code.
When I request ident.me, it returns a TOR IP address. However, when I request https://facebookcorewwwi.onion, I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mary\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "C:\Users\mary\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\mary\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Users\mary\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: SOCKSHTTPSConnectionPool(host='facebookcorewwwi.onion', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x035E1148>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
I've tried setting a timeout, but that doesn't seem to be working either. Every time I Google this problem, the answer takes me to a 3-year-old blog with something I've already tried.
EDIT: Before starting, I:
pip install requests[socks]
pip install requests[security]
I'm running Python 3.8.