Python使用赤舞代理的socks5采集实例


#Python使用赤舞代理的socks5采集实例转载:http://helpserver.chiwudaili.com/detail.aspx?id=a73406e4bdcc01ae615b649bf994bfb5#################################################################################
import json
from time import sleep
import requests
#################################################################################
def MyRequestGet(url,decode,proxyIPAndPort):
print(“MyRequestGet({0},{1},{2})IN”.format(url,decode,proxyIPAndPort))
headers = {‘User-Agent’: ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36’}
rel = “”;
if (len(proxyIPAndPort)>0):
proxies = {‘http’: ‘socks5://ip:port’,’https’:’socks5://ip:port’}
proxies[‘http’]=”socks5://{0}”.format(proxyIPAndPort)
proxies[‘https’]=”socks5://{0}”.format(proxyIPAndPort)
#print(proxies)
response = requests.get(url, proxies=proxies)
rel = response.content.decode(decode);
else:
response = requests.get(url)
rel = response.content.decode(decode);
print(“MyRequestGet()OUT:{0}”.format(rel))
return rel
#################################################################################
def MyGetPorxyIPAndPortFromChiWuDaiLi(phoneNumber,password):
rel = “”;
while (True):
try:
path = ‘http://mainserver.chiwudaili.com:8000/api/GetProxyIPsAndPorts.ashx?’;
param = ‘UserPhoneNumber={0}&UserPassword={1}&Count=1’.format(phoneNumber,password)
url = “{0}{1}”.format(path,param)
stringJson = MyRequestGet(url,’utf-8′,””)
objectJson = json.loads(stringJson)
if (objectJson[‘Code’] == 0):
if (objectJson[‘Data’][‘State’] == 0):
for index,value in enumerate(objectJson[‘ 香港云主机Data’][‘IPs’]):
rel = “{0}:{1}”.format(value[‘IP’],value[‘Port’])
return rel;
else:
print(objectJson[‘Data’][‘Error’])
sleep(5);
else:
print(objectJson[‘Message’])
sleep(5);
except Exception as err:
print(err)
sleep(1);
return rel;
#################################################################################
def MyMain(phoneNumber,password):
print (“MyMain() IN”);
while (True):
#url = ‘http://2018.ip138.com/ic.asp’;decode=’gb2312′;
url = ‘http://helpserver.chiwudaili.com/’;decode=’utf-8′;
#url = ‘https://www.baidu.com/’;decode=’utf-8′;
proxyIPAndPort = MyGetPorxyIPAndPortFromChiWuDaiLi(phoneNumber,password)
try:
while (True):
if (len(proxyIPAndPort)>0):
result = MyRequestGet(url,decode,proxyIPAndPort);
print(result)
else:
print(‘Get Proxy IP And Port Failed!’)
sleep(1);
except Exception as err:
print(err)
finally:
print(‘do nothing’)
sleep(1);
print (“MyMain() OUT”);
#################################################################################
#MyMain(‘您手机号码’,’密码’)
MyMain(‘13000000000′,’000000’)
#################################################################################

相关推荐: css如何修改input输入框中光标的颜色不改变字体的颜色

小编给大家分享一下css如何修改input输入框中光标的颜色不改变字体的颜色,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!修改input输入框中光标的颜色不改变字体的颜色看完了这篇文章,相信你对“css如何修改input输入框中光标的颜色不改…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

Like (0)
Donate 微信扫一扫 微信扫一扫
Previous 07/24 11:11
Next 07/24 11:12

相关推荐