python学习笔记(7)--爬虫隐藏代理
2024-10-19 16:33:02
说明:
1. 好像是这个网站的代理http://www.xicidaili.com/
2. 第2,3行的模块不用导入,之前的忘删了。。
3. http://www.whatismyip.com.tw/这个网站可以查看本机ip
4. 指定代理,创建代理,安装代理,打开链接,over。。
5. urllib.request.ProxyHandler({"http":"110.72.20.12:8123"}) -> urllib.request.build_opener -> request.install_opener -> urllib.request.urlopen
import urllib.request
import urllib.parse
import json iplist = ["110.72.20.12:8123","180.76.154.5:8888"]
proxies = {
"http": "http://10.10.1.10:3128",
"https": "http://10.10.1.10:1080",
}
url = "http://www.whatismyip.com.tw/"
# url = "http://www.tuwenclub.com" proxy_support = urllib.request.ProxyHandler({"http":"110.72.20.12:8123"})
opener = urllib.request.build_opener(proxy_support)
opener.addheaders = [("User-Agent","Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.22 Safari/537.36 SE 2.X MetaSr 1.0")]
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
html = response.read().decode("utf-8") print(html)
最新文章
- 【转】c3p0详细配置
- 字符输入流Reader简要概括
- JSONModel 嵌套字典数组 JSONModel nest NSDictionary NSArray
- cocos2d-x内存管理(见解)
- 批量 kill mysql 中运行时间长的sql
- 用定时器令P0(或其它IO口)产生多路方波
- uLua 学习笔记 之一 lua脚本 打包与读取
- bzoj 3242: [Noi2013]快餐店 章鱼图
- python学习随笔
- 跟我学android-常用控件之 TextView
- dage手法之 头部和banner ad tpl_header
- SQLite:自学笔记(1)——快速入门
- vmware fusion 10/pro 10序列号
- 开源IMDG之GridGain
- 距离度量以及python实现(一)
- 基于Windows服务的WCF
- 神经网络架构pytorch-MSELoss损失函数
- intelij idea设置和使用git
- Zabbix告警脚本-微信
- SQL Server中的数据类型
热门文章
- mysql的正则表达式
- 小课堂week18 编程范式巡礼第三季 谈谈依赖反转
- Oracle spatial抽稀函数(SDO_UTIL.SIMPLIFY)
- .NET破解之爱奇迪(三)
- Ext.encode 与 Ext.decode .
- python环境变量的配置
- jquery prop('checked', true)解决attr('checked', true)不能选中radio问题
- 一对一关系数据库表 java类描述
- MySQL学习记录一
- Postman+Postman interceptor的安装和使用-解决把chrome浏览器登录状态同步到postman进行有依赖的接口测试 Postman 使用方法详解