import httplib, urllib
params = urllib.urlencode( \
{'parameter': pValue, "p":valuep})
headers = { "Content-type": "text/xml,charset=utf-8"}
conn = httplib.HTTPConnection(self.webHost+":"+self.webPort)
conn.request("POST", "/"+self.webPath+"/?"+params, content , headers)
response = conn.getresponse()
print response.status, response.reason
print response.read()
conn.close()
char const* greet(unsigned x)
{
static char const* const msgs[] = { "hello", "Boost.Python", "world!" };
if (x > 2)
return "nothing";
return msgs[x];
}
def iptest(ip) :
c = pycurl.Curl()
c.setopt(c.URL, "http://www.ip138.com/ip2city.asp")
# 绑定到特定的IP地址
c.setopt(pycurl.INTERFACE,ip)
c.perform()
c.fp = StringIO.StringIO()
print c.fp.getvalue()
c.close()
def executeChangeable():
pid = os.getpid()
random.seed()
randpart = random.randint(10000000, 99999999)
return pid, randpart
def getproxycn():
portDict = {"R":"8","D":"0","C":"1","M":"4","Z":"3","K":"2","I":"7","L":"9","B":"5","W":"6"};
pagenum = 0
num = 0;
proxyfile = "proxys.txt"
file = open(proxyfile,"w+");
while pagenum <= 9:
url='http://www.cnproxy.com/proxy'+str(pagenum + 1)+'.html'
html=urllib2.urlopen(url)
for line in html:
if "HTTP" in line:
arra = line.upper().split("<TR><TD>")
arrb = arra[1].split("<SCRIPT TYPE=TEXT/JAVASCRIPT>")
ip = arrb[0]
port = arrb[1].split(")</SCRIPT>")[0].split("DOCUMENT.WRITE(\":\"")[1]
port = port.replace("+","");
p = "";
for i in range(len(port)):
alph = port[i:i+1]
p += portDict[alph];
print ip + ":" + p
file.write(ip+":"+p+"\n")
num += 1;
pagenum += 1;
file.close();
print "已处理代理总条数 : " + str(num)