代码拉取完成,页面将自动刷新
# 代理相关知识及实例。
# 及反扒策略之一 破解封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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。