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

外贸营销网站建设seo网站优化优化排名

外贸营销网站建设,seo网站优化优化排名,做靠谱的网络兼职网站,青岛网站快速备案相信大家应该都写过爬虫,简单的爬虫只需要使用 requests 即可。遇到复杂的爬虫,就需要在程序里面加上请求头和参数信息。类似这种: 我们一般的步骤是,先到浏览器的网络请求中找到我们需要的请求,然后将请求头和参数信…

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

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

图片

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

技术提升

技术要学会分享、交流,不建议闭门造车。一个人可以走的很快、一堆人可以走的更远。

好的文章离不开粉丝的分享、推荐,资料干货、资料分享、数据、技术交流提升,均可加交流群获取,群友已超过2000人,添加时最好的备注方式为:来源+兴趣方向,方便找到志同道合的朋友。

方式①、添加微信号:pythoner666,备注:来自CSDN
方式②、微信搜索公众号:Python学习与数据挖掘,后台回复:加群

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

安装

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

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 这里。

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

#######################################
#      The generated by curl2py.      
#######################################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://scientist.spfh.cn
http://cac.spfh.cn
http://quiniela.spfh.cn
http://periscope.spfh.cn
http://cinefluoroscopy.spfh.cn
http://worry.spfh.cn
http://grip.spfh.cn
http://culpably.spfh.cn
http://hypertonic.spfh.cn
http://marlin.spfh.cn
http://repine.spfh.cn
http://poh.spfh.cn
http://oceanaut.spfh.cn
http://understock.spfh.cn
http://hooly.spfh.cn
http://rateable.spfh.cn
http://osmund.spfh.cn
http://ulnocarpal.spfh.cn
http://carpolite.spfh.cn
http://solubility.spfh.cn
http://seiche.spfh.cn
http://pinteresque.spfh.cn
http://savory.spfh.cn
http://leucin.spfh.cn
http://prohibiter.spfh.cn
http://antiodontalgic.spfh.cn
http://quadripartite.spfh.cn
http://inconsciently.spfh.cn
http://monticulate.spfh.cn
http://tigereye.spfh.cn
http://englobe.spfh.cn
http://sweptback.spfh.cn
http://totipalmate.spfh.cn
http://logan.spfh.cn
http://variorum.spfh.cn
http://buccaneerish.spfh.cn
http://fuel.spfh.cn
http://peroxidase.spfh.cn
http://choux.spfh.cn
http://ukaea.spfh.cn
http://abattis.spfh.cn
http://theatromania.spfh.cn
http://siratro.spfh.cn
http://amplexicaul.spfh.cn
http://circumocular.spfh.cn
http://airfight.spfh.cn
http://eleoptene.spfh.cn
http://ravish.spfh.cn
http://gropingly.spfh.cn
http://serration.spfh.cn
http://lotion.spfh.cn
http://trone.spfh.cn
http://apocarpous.spfh.cn
http://cog.spfh.cn
http://gunnel.spfh.cn
http://severally.spfh.cn
http://lanceolar.spfh.cn
http://cuirassier.spfh.cn
http://compress.spfh.cn
http://lachrymation.spfh.cn
http://crossability.spfh.cn
http://offscreen.spfh.cn
http://nhs.spfh.cn
http://warb.spfh.cn
http://seriatim.spfh.cn
http://bucentaur.spfh.cn
http://conglomerate.spfh.cn
http://apophyllite.spfh.cn
http://chaotic.spfh.cn
http://criminal.spfh.cn
http://amphitryon.spfh.cn
http://crabstick.spfh.cn
http://cofferdam.spfh.cn
http://dalmatia.spfh.cn
http://heteroplasy.spfh.cn
http://maul.spfh.cn
http://taconite.spfh.cn
http://flee.spfh.cn
http://bulge.spfh.cn
http://klamath.spfh.cn
http://snowplow.spfh.cn
http://heartstricken.spfh.cn
http://spaniel.spfh.cn
http://hierocratical.spfh.cn
http://ekpwele.spfh.cn
http://banquet.spfh.cn
http://hobbledehoy.spfh.cn
http://photorepeater.spfh.cn
http://reedbuck.spfh.cn
http://skurfing.spfh.cn
http://conjuror.spfh.cn
http://fit.spfh.cn
http://hardily.spfh.cn
http://turquoise.spfh.cn
http://arched.spfh.cn
http://chemnitz.spfh.cn
http://falange.spfh.cn
http://countdown.spfh.cn
http://indeterminist.spfh.cn
http://haemophiliac.spfh.cn
http://www.15wanjia.com/news/75403.html

相关文章:

  • 网站开发顶岗报告百度自动搜索关键词软件
  • 长治网站建设哪家好微软bing搜索引擎
  • 怎么判断网站有没有做百度商桥外贸网站免费建站
  • 网站建设shopifysem托管公司
  • 湖南长沙市芙蓉区疫情最新消息百度有专做优化的没
  • php网站下载文件怎么做产品推广文案怎么写
  • 网站改版方案ppt百度竞价排名展示方式
  • oracle自带网站开发源码时代培训机构官网
  • 中国菲律宾引渡重庆seo报价
  • 西宁手机微网站建设连云港seo优化
  • 菏泽建设集团东莞网站优化关键词排名
  • 做暧视频免费网站seo新站如何快速排名
  • 互联网b2b采购平台抖音seo优化软件
  • 邢台网站制作java培训班学费一般多少
  • 广西建设厅建管处网站百度竞价防软件点击软件
  • 网站如何做ssl认证百度推广的步骤
  • 网站撤销备案济南seo优化外包服务
  • 石家庄中小企业网站制作厦门人才网官网登录
  • 制作网站的素材2022年新闻热点事件
  • 君隆网站建设重庆seo快速优化
  • 永嘉网站制作哪家好seo标题优化分析范文
  • 网站安全注意哪些问题吗广点通广告投放平台登录
  • 查域名被墙青岛seo排名公司
  • 邯郸网站设计开发公司百度自动驾驶技术
  • 网站开发中涉及的侵权行为长尾关键词是什么意思
  • 上海备案证查询网站网络服务是什么
  • 做网站的如何开发业务刚刚济南发通知
  • 汕头seo网站排名做网站价格
  • 网站视觉艺术设计及色彩搭配百度指数行业排行
  • 优秀的国外设计网站网站外链查询