Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

[Help] Deleting bad proxies from file

So I found a proxy checker I wanted to edit it to where I could delete faulty proxies if they didn't work from my textfile, but I have it select a random line from my textfile so I don't know how to delete it. I was thinking maybe searching for the proxy in the file and then deleting the line its on but have no idea how to do that?

PHP Code

<?php 
def is_bad_proxy
(pip):    
try:
    
proxy_handler = urllib2.ProxyHandler({'http': pip})
    
opener = urllib2.build_opener(proxy_handler)
    
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    
urllib2.install_opener(opener)
    
req=urllib2.Request('http://whatismyipaddress.com/') 
    
sock=urllib2.urlopen(req)
except urllib2.HTTPError, e:
    print 
'Error code: ', e.code
    
return e.code
except Exception
, detail:
    print 
"ERROR:", detail
    
return True
return False

def main
():
    
socket.setdefaulttimeout(120)
    
proxyList = [random.choice(open('proxies.txt', 'r').readlines())]

for 
currentProxy in proxyList:
    if 
is_bad_proxy(currentProxy):
        print 
"Bad Proxy %s" % (currentProxy)
        
#where i need to put the code where I delete the proxy
        
main()
    else:
        print 
"%s is working" % (currentProxy)
        global 
currentProxy 
Bump! if anyone knows how to do this please help
Bump! if anyone knows how to do this please help
You have them into a list, so i guess you just use the list.remove() to remove the proxy :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by HolocaustMar 13, 2016 10:32 PM 7 226 Mar 13, 2016 10:32 PM
Last Post: DudeyDance
[.NET] by Tha SneakApr 16, 2015 02:57 PM 5 168 Apr 16, 2015 02:57 PM
Last Post: Zyklon A
[C] by 55555onlineMar 17, 2014 08:34 PM 2 90 Mar 17, 2014 08:34 PM
Last Post: eldoradoKing