1 Star 0 Fork 0

xyislove/python-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
代理的相关应用.py 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
xyislove 提交于 2022-01-03 23:16 . 2022.1.3
# 代理相关知识及实例。
# 及反扒策略之一 破解封ip的反扒机制
# 什么是代理
# 即代理服务器。
# 代理的作用
# 可以突破自身ip访问的限制
# 可以隐藏自身真实ip
# 常用获取免费代理的网站
# --快代理
# --西柯代理
# --www.goubanjia.com
# https://www.kuaidaili.com/free/
# https://www.zdaye.com/dayProxy/2021/12/1.html
# 代理ip的匿名度
# 透明 服务器可以知道真实ip
# 匿名 知道使用了代理 不知道真实ip
# 高匿名 不知道使用了代理 更不知道真实ip
# 代理ip类型
# http: 应用到http协议对应的url中
# https: 应用到https协议对应的url中
# requests模块的代理使用
# get中添加proxies参数
# proxies={
# "http":"http//ip"
# 或
# "https":"https//ip"
# }217.113.122.142 3128
# 14.115.106.223 808
import requests
from fake_useragent import UserAgent
import random
# 测试 url='https://www.baidu.com/s?wd=ip'
ua=UserAgent()
headers={'User-Agent':ua.random}
url='https://www.baidu.com/s?wd=ip'
proxies={
"http":"http://8.218.86.158:59394"
}
resp=requests.get(url=url,headers=headers,proxies=proxies)
resp.close()
resp=resp.content.decode('utf-8')
with open('./ip.html',mode='w',encoding='utf-8') as f:
f.write(resp)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xyislove/python-test.git
git@gitee.com:xyislove/python-test.git
xyislove
python-test
python-test
master

搜索帮助