Answer the question
In order to leave comments, you need to log in
How to make Python code work after catching an error but with new values in a variable?
The essence of the question in # comments to the code
import requests
import urllib
from random import choice
from colorama import Fore, Back, Style
url = "http://3g2upl4pq6kufc4m.onion" # контрольный адрес для проверки работоспособности (код 200)
def ururu(): # генерирует рандомный URL
digits = "abcdefghijklmnopqrstuvwxyz234567"
adr = "http://" + "".join([choice(digits) for _ in range(16)]) + '.onion'
return adr
def getdata(adr):
try:
print(Fore.GREEN +"I will try => " '%s' %(adr))
proxies = {'http': 'socks5h://127.0.0.1:9050','https': 'socks5h://127.0.0.1:9050'}
data = requests.get(adr, proxies=proxies)
t = data.status_code == requests.codes.ok
print("Site data " '%s' % (data))
print("Response " '%s' %(t))
except requests.exceptions.InvalidURL:
print("InvalidURL")
except requests.ConnectionError: # но как скормить переменной новый URL после отлова ошибки?()
print("ConnectionError") # при каждом неверном адресе будет ошибка.Как перебрать Все url?
return data
Answer the question
In order to leave comments, you need to log in
What prevents a function from calling itself in an instance with a "different" parameter
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question