M
M
my_drone2017-10-05 17:34:04
Python
my_drone, 2017-10-05 17:34:04

PySocks error `0x04` - Host unreachable. how to handle the error and continue executing the code?

I am writing a program that checks Tor sites for availability (operability), but
I get an error:
PySocks error `0x04` - Host unreachable. when trying to access a non-existent .onion URL
Error description from the PySocks library documentation:
"`0x04` - Host unreachable - The target could not be contacted. A router on the network
had replied with a destination host unreachable error.
"
how to handle this error so that the code would continue executing even after the appearance of such an error??

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex F, 2017-10-05
@delvin-fil

import decimal, sys, re, math,  urllib, subprocess, random, warnings
PIPE = subprocess.PIPE
warnings.filterwarnings("ignore")
check = subprocess.Popen("torify curl -s http://icanhazip.com/",stderr=None, stdout=PIPE, shell=PIPE)
check = str(check.stdout.read())

What won't work?

M
my_drone, 2017-10-07
@my_drone

in general, in my case, catching errors of the following order helped :

except requests.ConnectionError:
except requests.exceptions.InvalidURL:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question