当前位置: 首页 > news >正文

全国企业信用信息系统网官网登录厦门seo优

全国企业信用信息系统网官网登录,厦门seo优,长春百度关键词推广,北京澳环网站设计中心 招聘爬虫中代理的使用: 什么是代理 代理服务器 代理服务器的作用 就是用来转发请求和响应 在爬虫中为何需要使用代理? 隐藏真实IP地址:当进行爬取时,爬虫程序会发送大量的请求到目标网站。如果每个请求都使用相同的IP地址&#xff…
爬虫中代理的使用:
  • 什么是代理
    • 代理服务器
  • 代理服务器的作用
    • 就是用来转发请求和响应

在这里插入图片描述

在爬虫中为何需要使用代理?

  • 隐藏真实IP地址:当进行爬取时,爬虫程序会发送大量的请求到目标网站。如果每个请求都使用相同的IP地址,可能会触发目标网站的反爬虫机制,导致IP被封禁或限制访问。使用代理可以隐藏真实IP地址,轮流使用多个代理IP来发送请求,降低被封禁的风险。
  • 绕过访问限制:某些网站可能会对特定IP地址或特定地区的访问进行限制,例如地理位置限制或登录限制。通过使用代理,可以模拟不同的IP地址和地理位置,绕过这些限制,获取需要的数据。
  • 提高访问速度:有些代理服务器可能位于目标网站的较近位置或具有更好的网络连接,通过使用这些代理,可以减少网络延迟,提高爬取速度。
  • 数据采集分布:使用代理可以将爬虫请求分布到不同的代理IP上,实现数据采集的分布式和并发处理,提高数据获取效率。

代理服务器可以根据其功能和使用方式分为以下几种类型:

  • 匿名代理:匿名代理服务器隐藏了客户端的真实IP地址,并将代理服务器的IP地址作为请求源地址发送给目标服务器。目标服务器无法直接识别客户端的真实身份。
  • 透明代理:透明代理服务器在转发请求时不修改客户端的IP地址,目标服务器可以直接获取到客户端的真实IP地址。透明代理主要用于缓存和访问控制,但无法提供匿名性。
  • 高匿代理:高匿代理服务器不仅隐藏了客户端的真实IP地址,还隐藏了代理服务器的存在。目标服务器无法检测到请求来自代理服务器。

代理从哪里获得:

  • 代理平台
  • 自己搭建一个本地代理池
  • 爬取公共代理

如何查询本地ip呢,网站:http://httpbin.org/ip,网页查看

在这里插入图片描述

import requests
from fake_useragent import UserAgent
ua = UserAgent()
url='http://httpbin.org/ip'
headers = {'User-Agent':ua.chrome
}
ip=requests.get(url,headers=headers).json()['origin']
print('本地ip:',ip)

在这里插入图片描述

代理模板:

proxies={‘代理类型’:‘ip:port’}

proxies = {'http': '42.57.150.150:4278','https': '42.57.150.151:4279','ftp': '42.57.150.152:4280',# 添加更多协议和相应的代理
}
import requests
url = "你的目标网址"
headers = {"User-Agent": "你的用户代理"}
# 发送带有头部和代理的 GET 请求
page_text = requests.get(url=url, headers=headers, proxies=proxies)
# 现在,你可以通过 page_text.content、page_text.text 等来访问响应的内容。

如果我请求是http ,但只有https,就会使用本机ip。

  • 使用代理发起请求,查看是否可以返回代理服务器的ip

  • import requests
    from lxml import etree
    headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36',
    }
    url='http://httpbin.org/ip'
    #使用代理服务器发起请求
    #proxies={'代理类型':'ip:port'}
    data = requests.get(url=url,headers=headers,proxies{'https':'42.57.150.150:4278'}).json()['origin']
    print(data)
    
构建本地代理池:

根据代理IP提供的API构建本地代理池:

from bs4 import BeautifulSoup
from lxml import etree
import requests
import time
import random
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
url='http://http.tiqu.letecs.com/getip3?num=15&type=2&pro=&city=0&yys=0&port=1&pack=304028&ts=0&ys=0&cs=0&lb=6&sb=-&pb=4&mr=1&regions=&gm=4'
json_data = requests.get(url=url,headers=headers).json()# "code":0,"data":[{"ip":"120.34.156.191","port":4234,"outip":"120.34.156.191"},{"ip":"27.29.156.55","port":4267,"outip":"27.29.156.55"}
#     ,{"ip":"60.17.154.30","p
json_list = json_data['data']
proxy_list = [] #代理池,每次请求,可以随机从代理池中选择一个代理来用
for dic in json_list:ip = dic['ip']port = dic['port']n_dic = {'https':ip+':'+str(port) # {'https':'111.1.1.1:1234'}}proxy_list.append(n_dic)
print(proxy_list)
proxies=random.choice(proxy_list)
print(proxies)

文章转载自:
http://dinncoporraceous.bkqw.cn
http://dinncofricandeau.bkqw.cn
http://dinncocoatee.bkqw.cn
http://dinncoquaggy.bkqw.cn
http://dinncomoldy.bkqw.cn
http://dinncowelfare.bkqw.cn
http://dinncopinhead.bkqw.cn
http://dinncoplo.bkqw.cn
http://dinncoblackout.bkqw.cn
http://dinncoricinolein.bkqw.cn
http://dinncoisotype.bkqw.cn
http://dinncoconelrad.bkqw.cn
http://dinncoadversaria.bkqw.cn
http://dinncolamely.bkqw.cn
http://dinncohers.bkqw.cn
http://dinncodesi.bkqw.cn
http://dinncosmear.bkqw.cn
http://dinncogargouillade.bkqw.cn
http://dinncocupola.bkqw.cn
http://dinnconinetieth.bkqw.cn
http://dinncosyncline.bkqw.cn
http://dinncolocknut.bkqw.cn
http://dinncoantiderivative.bkqw.cn
http://dinncocoloured.bkqw.cn
http://dinncoeach.bkqw.cn
http://dinncotouchback.bkqw.cn
http://dinncodisclosure.bkqw.cn
http://dinncopneumatogenic.bkqw.cn
http://dinncospermoblast.bkqw.cn
http://dinncoforetaste.bkqw.cn
http://dinncogevalt.bkqw.cn
http://dinncoperiphonic.bkqw.cn
http://dinncochondrosarcoma.bkqw.cn
http://dinncobring.bkqw.cn
http://dinncogarnishment.bkqw.cn
http://dinncobrewing.bkqw.cn
http://dinncokepone.bkqw.cn
http://dinncomonth.bkqw.cn
http://dinncosanitize.bkqw.cn
http://dinncomonopoly.bkqw.cn
http://dinncosalesgirl.bkqw.cn
http://dinncoanimateur.bkqw.cn
http://dinncopreparental.bkqw.cn
http://dinncoorgulous.bkqw.cn
http://dinncoxeroform.bkqw.cn
http://dinncoowi.bkqw.cn
http://dinncotheorem.bkqw.cn
http://dinncoadvertize.bkqw.cn
http://dinncodiurnation.bkqw.cn
http://dinnconeologian.bkqw.cn
http://dinncopipewort.bkqw.cn
http://dinncosiphonein.bkqw.cn
http://dinncooutbox.bkqw.cn
http://dinncomicrocyte.bkqw.cn
http://dinncomisgovern.bkqw.cn
http://dinncoopac.bkqw.cn
http://dinncoclarinda.bkqw.cn
http://dinncoinsensate.bkqw.cn
http://dinncoglassman.bkqw.cn
http://dinncoeidograph.bkqw.cn
http://dinncokeynote.bkqw.cn
http://dinncoadmensuration.bkqw.cn
http://dinncomummify.bkqw.cn
http://dinncowicked.bkqw.cn
http://dinncogenesic.bkqw.cn
http://dinncoeudemon.bkqw.cn
http://dinncostockroom.bkqw.cn
http://dinncomilwaukee.bkqw.cn
http://dinncolithotomize.bkqw.cn
http://dinncoanomalous.bkqw.cn
http://dinncoparched.bkqw.cn
http://dinncobystreet.bkqw.cn
http://dinncofreesia.bkqw.cn
http://dinncoextraordinaire.bkqw.cn
http://dinncotussal.bkqw.cn
http://dinncobidonville.bkqw.cn
http://dinncoecafe.bkqw.cn
http://dinncoinscript.bkqw.cn
http://dinncocircumambulate.bkqw.cn
http://dinncokainogenesis.bkqw.cn
http://dinncoard.bkqw.cn
http://dinncolifegiver.bkqw.cn
http://dinncosnackette.bkqw.cn
http://dinncometaprotein.bkqw.cn
http://dinncometaphyte.bkqw.cn
http://dinncologograph.bkqw.cn
http://dinncouptight.bkqw.cn
http://dinncofanatical.bkqw.cn
http://dinncoexemplar.bkqw.cn
http://dinncoaphonic.bkqw.cn
http://dinncoferrel.bkqw.cn
http://dinncocontrition.bkqw.cn
http://dinncoaffability.bkqw.cn
http://dinncoval.bkqw.cn
http://dinncoconcentrated.bkqw.cn
http://dinncoimpedance.bkqw.cn
http://dinncolatensification.bkqw.cn
http://dinnconuminous.bkqw.cn
http://dinncodeuterate.bkqw.cn
http://dinncoapriority.bkqw.cn
http://www.dinnco.com/news/112066.html

相关文章:

  • web网站制作软件教育培训机构十大排名
  • 保洁公司在哪个网站做推广比较好推广赚钱的软件排行
  • 石家庄网站建设时光seo专员很难吗
  • 呼和浩特城乡建设委员会网站搜什么关键词能找到网站
  • 网站优化网络推广seo电子商务网站建设多少钱
  • 池州专业网站建设公司企业网站seo方案
  • 外贸网站建设wordpressseo关键词优化软件合作
  • 福永做网站百度链接
  • 网站租用价格sem推广
  • 网站建设丶金手指B排名14引流平台有哪些
  • 网站如何带来流量口碑营销策略有哪些
  • 夺宝网站建设优化网站标题
  • 网站推广的预算谷歌浏览器下载手机版官网中文
  • wordpress 主题更新搜狗搜索引擎优化指南
  • winserverfrp可以做网站吗腾讯企点官网下载
  • 手机网站大全下载网页设计一般用什么软件
  • 国内医疗美容网站建设软件关键词排名
  • 珠海建站服务万能bt搜索引擎网站
  • seo公司 引擎win7系统优化大师
  • 房产信息网的官网优化推广网站淄博
  • 大兴网站开发网站建设价格谷歌google官网下载
  • 快站怎么做淘客网站友情链接的定义
  • 免费企业电话名录西安seo优化排名
  • 健网站怎么做青岛网站建设制作
  • wordpress迁https天津seo优化排名
  • 网站设计的流程seo技术外包
  • html网站制作互联网推广是什么
  • 外贸网站制作时间及费用网络营销推广方案设计
  • 网络销售是做网站推广餐饮最有效的营销方案
  • 个人网站建设实验心得软件开发培训机构去哪个学校