首页 > 其他 > 详细

代理服务器

时间:2018-05-21 10:01:20      阅读:988      评论:0      收藏:0      [点我收藏+]

代理网址 http://www.xicidaili.com

urllib.request.ProxyHandler({"http":端口})

//代理操作

urllib.request.build_opener(代理名,urllib.request,HTTPHandler)

 

import urllib.request

//代理模块都request下
def use_proxy(url,duan):

//用函数对代理简单操作
file=urllib.request.ProxyHandler({"http":duan})
tom=urllib.request.build_opener(file,urllib.request.HTTPHandler)
urllib.request.install_opener(tom)
date=urllib.request.urlopen(url).read().decode("utf-8","ignore")

//把爬取值解码为utf-8格式
return date
url="http://www.baidu.com"
duan="119.28.194.66:8888"
wang=use_proxy(url,duan)
print(len(wang))

//操作完毕

代理服务器

原文:https://www.cnblogs.com/chunqing/p/9065569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!