Python使用赤舞代理的socks5采集實(shí)例

#Python使用赤舞代理的socks5采集實(shí)例

成都創(chuàng)新互聯(lián)是少有的網(wǎng)站制作、成都網(wǎng)站制作、營(yíng)銷(xiāo)型企業(yè)網(wǎng)站、小程序開(kāi)發(fā)、手機(jī)APP,開(kāi)發(fā)、制作、設(shè)計(jì)、買(mǎi)鏈接、推廣優(yōu)化一站式服務(wù)網(wǎng)絡(luò)公司,自2013年創(chuàng)立以來(lái),堅(jiān)持透明化,價(jià)格低,無(wú)套路經(jīng)營(yíng)理念。讓網(wǎng)頁(yè)驚喜每一位訪(fǎng)客多年來(lái)深受用戶(hù)好評(píng)

轉(zhuǎn)載: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('您手機(jī)號(hào)碼','密碼')
MyMain('13000000000','000000')
#################################################################################

新聞名稱(chēng):Python使用赤舞代理的socks5采集實(shí)例
網(wǎng)站地址:http://bm7419.com/article0/ipocoo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、定制網(wǎng)站外貿(mào)網(wǎng)站建設(shè)、企業(yè)建站、企業(yè)網(wǎng)站制作、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化