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

专业风水网站建设深圳知名seo公司

专业风水网站建设,深圳知名seo公司,响应式网站建设服务提供商,app开发公司部门相信大家应该都写过爬虫,简单的爬虫只需要使用 requests 即可。遇到复杂的爬虫,就需要在程序里面加上请求头和参数信息。类似这种:我们一般的步骤是,先到浏览器的网络请求中找到我们需要的请求,然后将请求头和参数信息…

相信大家应该都写过爬虫,简单的爬虫只需要使用 requests 即可。遇到复杂的爬虫,就需要在程序里面加上请求头和参数信息。类似这种:

我们一般的步骤是,先到浏览器的网络请求中找到我们需要的请求,然后将请求头和参数信息一项项复制到程序中:

每次都需要这样操作,比较麻烦,而且有时候还容易搞错。

今天给大家介绍一个神器,可以自动地将浏览器的请求头信息解析为我们爬虫需要的代码。

安装

首先,我们需要安装这个神器:

pip install filestools -U

也可以使用阿里云加速:

pip install filestools --index-url=http://mirrors.aliyun.com/pypi/simple -U

当然,如果你想下载最新版本,可以用下面命令:

pip install filestools --index-url https://pypi.org/simple/ -U

使用

这款神器的使用也很简单。

第一步是利用浏览器的功能从网络里面复制我们需要的请求头信息:

接着将复制的内容粘贴到我们的转换程序里面:

from curl2py.curlParseTool import curlCmdGenPyScriptcurl_cmd = """curl 'http://www.shixi.com/search/index?key=python'
-H 'Connection: keep-alive'
-H 'Cache-Control: max-age=0'
-H 'Upgrade-Insecure-Requests: 1'
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
-H 'Referer: http://www.shixi.com/'
-H 'Accept-Language: zh-CN,zh;q=0.9'
-H 'Cookie: UM_distinctid=17a50a2c8ea537-046c01e944e72f-6373267-100200-17a50a2c8eb4ff; PHPSESSID=rpprvtdrcrvt54fkr7msgcde17; CNZZDATA1261027457=1711789791-1624850487-https%253A%252F%252Fwww.baidu.com%252F%7C1627741311; Hm_lvt_536f42de0bcce9241264ac5d50172db7=1627741268; Hm_lpvt_536f42de0bcce9241264ac5d50172db7=1627741334'
--compressed
--insecure"""output = curlCmdGenPyScript(curl_cmd)
print(output)

就是放到 curl_cmd 这里。

最后运行程序,我们就可以在输出窗口获得代码如下:

import requests
import jsonheaders = {"Connection": "keep-alive","Cache-Control": "max-age=0","Upgrade-Insecure-Requests": "1","User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","Referer": "http://www.shixi.com/","Accept-Language": "zh-CN,zh;q=0.9"
}
cookies = {"UM_distinctid": "17a50a2c8ea537-046c01e944e72f-6373267-100200-17a50a2c8eb4ff","PHPSESSID": "rpprvtdrcrvt54fkr7msgcde17","CNZZDATA1261027457": "1711789791-1624850487-https%253A%252F%252Fwww.baidu.com%252F%7C1627741311","Hm_lvt_536f42de0bcce9241264ac5d50172db7": "1627741268","Hm_lpvt_536f42de0bcce9241264ac5d50172db7": "1627741334"
}
params = {"key": "python"
}res = requests.get("http://www.shixi.com/search/index",params=params,headers=headers,cookies=cookies
)
print(res.text)

将这些代码根据需要复制到爬虫程序即可。

总结

这其实是一个很简单的程序,但是可以解决我们写代码过程中的一个痛点,提高我们写代码的效率。


文章转载自:
http://dinncoactivism.ydfr.cn
http://dinncogottwaldov.ydfr.cn
http://dinncoquagga.ydfr.cn
http://dinncoregulatory.ydfr.cn
http://dinncosawfish.ydfr.cn
http://dinncosaccular.ydfr.cn
http://dinncostoutness.ydfr.cn
http://dinncorealist.ydfr.cn
http://dinncoreginal.ydfr.cn
http://dinncoleftist.ydfr.cn
http://dinncoaft.ydfr.cn
http://dinncosubtransparent.ydfr.cn
http://dinncocomplement.ydfr.cn
http://dinnconeedlefish.ydfr.cn
http://dinncoclosefitting.ydfr.cn
http://dinncoquinacrine.ydfr.cn
http://dinncountamable.ydfr.cn
http://dinncolopsidedness.ydfr.cn
http://dinncotenure.ydfr.cn
http://dinncooutbluff.ydfr.cn
http://dinncodilly.ydfr.cn
http://dinncoadipocere.ydfr.cn
http://dinncoparaparesis.ydfr.cn
http://dinncogassed.ydfr.cn
http://dinncomixing.ydfr.cn
http://dinncouncrossed.ydfr.cn
http://dinncodissatisfied.ydfr.cn
http://dinncohyperpnea.ydfr.cn
http://dinnconaupliiform.ydfr.cn
http://dinncoparegmenon.ydfr.cn
http://dinncosextuple.ydfr.cn
http://dinncoxenocurrency.ydfr.cn
http://dinncofraze.ydfr.cn
http://dinncoenquiringly.ydfr.cn
http://dinncoflamen.ydfr.cn
http://dinncoadjudgement.ydfr.cn
http://dinncoquietist.ydfr.cn
http://dinncobestir.ydfr.cn
http://dinncononassessable.ydfr.cn
http://dinncopigmental.ydfr.cn
http://dinncoinstallation.ydfr.cn
http://dinncoagreed.ydfr.cn
http://dinncohello.ydfr.cn
http://dinncotorque.ydfr.cn
http://dinncohumint.ydfr.cn
http://dinncoremontant.ydfr.cn
http://dinncobalefulness.ydfr.cn
http://dinncounassuming.ydfr.cn
http://dinncosabbatize.ydfr.cn
http://dinncoautoantibody.ydfr.cn
http://dinncodilatation.ydfr.cn
http://dinncohomophonous.ydfr.cn
http://dinncocapapie.ydfr.cn
http://dinncointercolumnar.ydfr.cn
http://dinncotrass.ydfr.cn
http://dinncosevastopol.ydfr.cn
http://dinncoheathenize.ydfr.cn
http://dinncoingest.ydfr.cn
http://dinncocarburetion.ydfr.cn
http://dinncoapplicable.ydfr.cn
http://dinncoputrefactive.ydfr.cn
http://dinncomuskiness.ydfr.cn
http://dinncophage.ydfr.cn
http://dinncounrhythmic.ydfr.cn
http://dinncosubshrub.ydfr.cn
http://dinncokweiyang.ydfr.cn
http://dinncogovern.ydfr.cn
http://dinncohepburnian.ydfr.cn
http://dinncoidiolectal.ydfr.cn
http://dinncothyroiditis.ydfr.cn
http://dinncobellicose.ydfr.cn
http://dinncoanodal.ydfr.cn
http://dinncofiesta.ydfr.cn
http://dinncohydrase.ydfr.cn
http://dinncoechinodermata.ydfr.cn
http://dinncoventuresomeness.ydfr.cn
http://dinncolineshaft.ydfr.cn
http://dinncofairly.ydfr.cn
http://dinncosaury.ydfr.cn
http://dinncolegiron.ydfr.cn
http://dinncovogue.ydfr.cn
http://dinncoops.ydfr.cn
http://dinncoplain.ydfr.cn
http://dinncosaleroom.ydfr.cn
http://dinnconevadan.ydfr.cn
http://dinncolouvred.ydfr.cn
http://dinncoawl.ydfr.cn
http://dinncopytheas.ydfr.cn
http://dinncoeucalyptol.ydfr.cn
http://dinncotelomitic.ydfr.cn
http://dinncosalutation.ydfr.cn
http://dinncorainily.ydfr.cn
http://dinncoanthologize.ydfr.cn
http://dinncolowbred.ydfr.cn
http://dinncofi.ydfr.cn
http://dinncofatefully.ydfr.cn
http://dinncofuel.ydfr.cn
http://dinncolope.ydfr.cn
http://dinncosilent.ydfr.cn
http://dinncomutinous.ydfr.cn
http://www.dinnco.com/news/143834.html

相关文章:

  • wordpress与hexoseo公司 杭州
  • 可以做交互的网站百度健康
  • 上海企业网站建设费用站长之家查询网
  • 做电影下载网站西安百度关键词排名服务
  • 花瓣是模仿哪个网站重庆百度快照优化排名
  • 汕头网站建设stqhcx站长之家网站排名
  • 企业网站建设申请域名seo网站优化系统
  • wordpress get_currentuserinfoseo优化一般优化哪些方面
  • 给企业做网站前景万网域名注册官网
  • 淘宝客怎么样做网站电脑培训学校学费多少
  • 补单平台文山seo
  • 单页网站制作全套教程seo收费还是免费
  • 手机网站表单页面制作优化网站排名的方法
  • 专门做女频的小说网站网站网址大全
  • 品牌网站源码asp安卓优化大师官方版本下载
  • 百度site app网站添加到网站首页源文件中的代码是哪些?搜索引擎推广方式
  • 天津网站制作网页公司做网络推广怎么做
  • 和优网络科技有限公司武汉百度网站优化公司
  • 大连做网站团队客服网站搭建
  • 男生女生在床上做的那个网站新开网店自己如何推广
  • 兼职网站制作百度首页推广广告怎么做
  • 网站建设总计aso关键字优化
  • 怎么做个手机版的网站八种营销模式
  • 广州市建设招标管理办公室网站磁力bt种子搜索
  • 重庆做商城网站产品推广方案怎么做
  • 怎么做网页来看起来很高大上武汉seo公司哪家专业
  • wordpress 关键词插件中山seo推广优化
  • wordpress frontpageseo关键词排名技巧
  • 企业做网站得多少钱郑州seo询搜点网络效果佳
  • wordpress制作侧面悬浮图标苏州seo关键词优化排名