import threading , requests
list = [
"balajidurgaceramics.com",
"km-associates.in",
"www.auifs.org",
"www.cadetcarebd.com",
"thaygiaoquocdan.vn",
"plastimedicos.com",
"www.styleprojectss.com",
"www.matricjackets.com",
"www.ottenandpartners.co.za"
"www.carteplastique.fr",
"hellocodersabbir.com",
"playrifa.com",
"amedgroup.net",
"alphatechservices.org.in",
"aaqildental.com",
"montessoriassociation.org.ua",
"amorehairandbeauty.co.u"
]
def test(url):
r = requests.get('http://'+url)
r = r.url
print(r)
for x in list:
t = threading.Thread(target=test, args=(x, ))
t.start()
I want to get http / https for every website in my list, but When i run it, i got an error
Some website can get the url(http&https),but arround 14-16 website only and the other website is not and getting an error
error :
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/data/data/com.termux/files/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/storage/emulated/0/termux/k.py", line 28, in test
r = requests.get('http://'+url)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Does anyone have a solution to fix my problem, i want all website in my list can get http or https depends of the website
Does anyone can help me fix this problem?
You forgot a comma between
"www.ottenandpartners.co.za"
"www.carteplastique.fr",
Hence python concatenated those strings into "www.ottenandpartners.co.zawww.carteplastique.fr"
which is not a valid URL, and therefore you got this error.
And in the last URL you wrote "amorehairandbeauty.co.u" instead of ".co.uk" (I guess).
And in fact, it has nothing to do with threads, the reason you thought that threads caused this is because with threads you got to that URL way more quickly than without threads, but after a few seconds of waiting for Python to reach this URL you would have encountered this error too.