юзаю это:
import thread, pycurl, StringIO, time, urllib, re
Python 2.6.2
Linux laptop 2.6.28-16-generic
в чём может быть трабла ?
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import thread, pycurl, StringIO, time, urllib, re
socks = open('socks.txt', 'r').readlines()
socks_count = len(socks)
check_socks_count = 0
good_socks = []
as_socks = []
socks_threads = 50 # колво потоков чека носков
if_check_socks = 1 # чекать носки?
def test_socks():
global socks, check_socks_count, good_socks, socks_count
while (len(socks) > 0):
sock = socks.pop().strip()
io = StringIO.StringIO()
curl = pycurl.Curl()
curl.setopt(pycurl.URL, 'http://ya.ru/')
curl.setopt(pycurl.CONNECTTIMEOUT, 10)
curl.setopt(pycurl.WRITEFUNCTION, io.write)
curl.setopt(pycurl.PROXY, sock)
curl.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
try:
curl.perform()
except pycurl.error, msg:
pass
else:
if len(io.getvalue())>100 :
good_socks.append(sock)
good = open('good_socks.txt', 'a')
good.write(sock + "\n")
good.close()
curl.close()
io.close()
check_socks_count += 1
if if_check_socks:
for i in xrange(0,socks_threads):
thread.start_new_thread(test_socks,())
while (socks_count>check_socks_count):
print 'Проверка носков: ' + str(round(check_socks_count * 100.0 / socks_count)) + '%'
time.sleep(1)
#pass
print 'Из ' + str(socks_count) + ' носков ' + str(len(good_socks)) + ' хороших'
for ss in good_socks:
as_socks.append({'sock':ss.strip(), 'status':0})
else:
for ss in socks:
if len(ss.strip()): as_socks.append({'sock':ss.strip(), 'status':0})
import signal
signal.signal(signal.SIGPIPE, signal.SIG_IGN)