Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:11:33+00:00 2026-06-04T21:11:33+00:00

i have some text file which contain proxy ip . which look like following

  • 0

i have some text file which contain proxy ip .

which look like following

    130.14.29.111:80                          
    130.14.29.120:80                          
    130.159.235.31:80                         
    14.198.198.220:8909                       
    141.105.26.183:8000                       
    160.79.35.27:80                           
    164.77.196.75:80                          
    164.77.196.78:45430                       
    164.77.196.78:80                          
    173.10.134.173:8081                       
    174.132.145.80:80                         
    174.137.152.60:8080                       
    174.137.184.37:8080                       
    174.142.125.161:80     

after processing check this proxy , then i want to marked as following

     total number of '0' = 8
     total number of 'x' = 6
     percentage = alive 60% , dead 40%


     x  130.14.29.111:80              
     0  130.14.29.120:80              
     0  130.159.235.31:80             
     0  14.198.198.220:8909           
     0  141.105.26.183:8000           
     0  160.79.35.27:80               
     x  164.77.196.75:80              
     x  164.77.196.78:45430           
     x  164.77.196.78:80              
     0  173.10.134.173:8081           
     0  174.132.145.80:80             
     0  174.137.152.60:8080           
     x  174.137.184.37:8080           
     x  174.142.125.161:80           

how can be done with python? or some sample
if anyone would help me or enlight me much aprreciate!

i was edited

this is script source of what i have

finally check finished proxy list are saved to ‘proxy_alive.txt’

in this file i want to mark whether proxy element alive or not.

    import socket
    import urllib2
    import threading
    import sys
    import Queue
    import socket

    socket.setdefaulttimeout(7)

    print "Bobng's proxy checker. Using %s second timeout"%(socket.getdefaulttimeout())

    #input_file = sys.argv[1]
    #proxy_type = sys.argv[2] #options: http,s4,s5
    #output_file = sys.argv[3]
    input_file = 'proxylist.txt'
    proxy_type = 'http'
    output_file = 'proxy_alive.txt'

    url = "www.seemyip.com" # Don't put http:// in here, or any /'s

    check_queue = Queue.Queue()
    output_queue = Queue.Queue()
    threads = 20

    def writer(f,rq):
        while True:
            line = rq.get()
            f.write(line+'\n')

    def checker(q,oq):
        while True:
            proxy_info = q.get() #ip:port
            if proxy_info == None:
                print "Finished"
            #quit()
                return
            #print "Checking %s"%proxy_info
            if proxy_type == 'http':
                try:

            listhandle = open("proxylist.txt").read().split('\n')

            for line in listhandle:   
                saveAlive = open("proxy_alive.txt", 'a')

                details = line.split(':')
                email = details[0]
                password = details[1].replace('\n', '')


                proxy_handler = urllib2.ProxyHandler({'http':proxy_info})
                opener = urllib2.build_opener(proxy_handler)
                opener.addheaders = [('User-agent','Mozilla/5.0')]
                urllib2.install_opener(opener)
                req = urllib2.Request("http://www.google.com")
                sock=urllib2.urlopen(req, timeout= 7)
                rs = sock.read(1000)
                if '<title>Google</title>' in rs:
                oq.put(proxy_info)
                print '[+] alive proxy' , proxy_info
                saveAlive.write(line)
            saveAlive.close()    
                except urllib2.HTTPError,e:
            print 'url open error? slow?'
                    pass
                except Exception,detail:
                    print '[-] bad proxy' ,proxy_info

            else:
                # gotta be socks
                try:
                    s = socks.socksocket()
                    if proxy_type == "s4":
                        t = socks.PROXY_TYPE_SOCKS4
                    else:
                        t = socks.PROXY_TYPE_SOCKS5
                    ip,port = proxy_info.split(':')
                    s.setproxy(t,ip,int(port))
                    s.connect((url,80))
                    oq.put(proxy_info)
                    print proxy_info
                except Exception,error:
                    print proxy_info

    threading.Thread(target=writer,args=(open(output_file,"wb"),output_queue)).start()
    for i in xrange(threads):
        threading.Thread(target=checker,args=(check_queue,output_queue)).start()
    for line in open(input_file).readlines():
        check_queue.put(line.strip('\n'))
    print "File reading done"
    for i in xrange(threads):
        check_queue.put(None)
    raw_input("PRESS ENTER TO QUIT")
    sys.exit(0)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:11:34+00:00Added an answer on June 4, 2026 at 9:11 pm

    Is this what you want?

    #!/usr/bin/env python
    import Queue
    import threading
    import urllib2
    import time
    
    input_file = 'proxylist.txt'
    threads = 10
    
    queue = Queue.Queue()
    output = []
    
    class ThreadUrl(threading.Thread):
        """Threaded Url Grab"""
        def __init__(self, queue):
            threading.Thread.__init__(self)
            self.queue = queue
    
        def run(self):
            while True:
                #grabs host from queue
                proxy_info = self.queue.get()
    
                try:
                    proxy_handler = urllib2.ProxyHandler({'http':proxy_info})
                    opener = urllib2.build_opener(proxy_handler)
                    opener.addheaders = [('User-agent','Mozilla/5.0')]
                    urllib2.install_opener(opener)
                    req = urllib2.Request("http://www.google.com")
                    sock=urllib2.urlopen(req, timeout= 7)
                    rs = sock.read(1000)
                    if '<title>Google</title>' in rs:
                        output.append(('0',proxy_info))
                    else:
                        raise "Not Google"
                except:
                    output.append(('x',proxy_info))
                #signals to queue job is done
                self.queue.task_done()
    
    start = time.time()
    def main():
    
        #spawn a pool of threads, and pass them queue instance 
        for i in range(5):
            t = ThreadUrl(queue)
            t.setDaemon(True)
            t.start()
        hosts = [host.strip() for host in open(input_file).readlines()]
        #populate queue with data   
        for host in hosts:
            queue.put(host)
    
        #wait on the queue until everything has been processed     
        queue.join()
    
    main()
    for proxy,host in output:
        print proxy,host
    
    print "Elapsed Time: %s" % (time.time() - start)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this text file which might contain some unsupported characters in the Latin1
I have text file with some stuff that i would like to put into
Greetings All; I have a LinkedList of type String which contain some words like
I have a text file which I'm trying to parse. The file looks like
I have a text file and I want to remove some lines that contain
Hi I have a text file which contains some numerical data. Of that text
I have plain text file ( .txt ) which has some expressions and I
I have text file with some text information and i need to split this
I have some code reading a text file and scanning for words between brackets:
We have some C# code that reads data from a text file using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.