How to test the proxies using Python 3?

Step 1: Download the Python from their official website.

Step 2: Open a Notepad/Text Editor and enter the following code.

import urllib.request , socket


# read the list of proxy IPs in proxyList

import tkinter as tk
from tkinter import simpledialog

ROOT = tk.Tk()

# the input dialog
USER_INP = simpledialog.askstring(title="Proxy", prompt="ProxyIP:Port")

# check it out
print("LimeProxies IP:", USER_INP)
proxyList = [USER_INP] # there are two sample proxy ip

def is_bad_proxy(pip):
proxy_handler = urllib.request.ProxyHandler({'http': pip})
opener = urllib.request.build_opener(proxy_handler)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
sock=urllib.request.urlopen('') # change the url address here
except urllib.error.HTTPError as e:
print('Error code: ', e.code)
return e.code
except Exception as detail:

print( "ERROR:", detail)
return 1
return 0

for item in proxyList:
if is_bad_proxy(item):
print ("Bad Proxy", item)
print (item, "is working")

Step 3: Save the file as

Step 4: Shift + Right Click on the folder where the file is saved and click on the Open Command window here.

Step 5: Type the following code to run the python code.


Step 6: Enter your proxy IP in the popup box

You will get the result as proxy working or bad proxy.

Did this answer your question?