iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python中requests库+xpath+lxml简单使用
  • 584
分享到

python中requests库+xpath+lxml简单使用

2024-04-02 19:04:59 584人浏览 薄情痞子

Python 官方文档:入门教程 => 点击学习

摘要

目录安装简单使用1.简单访问一个url:2.带参数访问url4.requests的一些常用方法和主要参数5.requests.Response对象的属性说明xpath简介lxml简介

python的requests

它是Python的一个第三方库,处理URL比urllib这个库要方便的多,并且功能也很丰富。
【可以先看4,5表格形式的说明,再看前面的】

安装

直接用pip安装,anconda是自带这个库的。


pip install requests

简单使用

requests的文档

1.简单访问一个url:


import requests
url='Http://www.baidu.com'
res = requests.get(url)
res.text
res.status_code

<!DOCTYPE html>
<!--STATUS OK-->
<html>
 <head>
<meta http-equiv=content-type content=text/html;charset=utf-8>
<meta http-equiv=X-UA-Compatible content=IE=Edge>
<meta content=always name=referrer>
<link rel=stylesheet type=text/CSS href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css>
<title>ç™¾åº¦ä¸€ä¸‹ï¼Œä½ å°±çŸ¥é“</title>
</head> 
<body link=#0000cc> 
<div id=wrapper> 
<div id=head> 
<div class=head_wrapper> 
<div class=s_fORM> 
<div class=s_form_wrapper>
 <div id=lg> 
<img hidefocus=true src=//www.baidu.com/img/bd_loGo1.jpg width=270 height=129> 
</div>
 <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> 
<input type=hidden name=ie value=utf-8> 
<input type=hidden name=f value=8> 
<input type=hidden name=rsv_bp value=1>
 <input type=hidden name=rsv_idx value=1> 
<input type=hidden name=tn value=baidu>
<span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span>
<span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span>
 </form>
 </div>
 </div>
 <div id=u1> 
<a href=http://news.baidu.com name=tj_trnews class=mnav>æ–°é—»</a>
 <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> 
<a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> 
<a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> 
<a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> 
<noscript> 
<a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3D1 name=tj_login class=lb>登录</a> </noscript>
 <script>
document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === " rel="external nofollow"  rel="external nofollow"  rel="external nofollow" " ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> 
<a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> 
</div> 
</div> 
</div> 
<div id=ftCon> 
<div id=ftConw> 
<p id=lh> 
<a href=http://home.baidu.com>å³äºŽç™¾åº¦</a>
 <a href=http://ir.baidu.com>About Baidu</a>
 </p> 
<p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前å¿
è&Macr;»</a>&nbsp; 
<a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>

200

乱码的,是由于没有转换字符,可以加入res.encoding='utf-8'解决,200是状态码。一般状态码是2xx都没什么问题的。

1xx:WEB服务器正确接收到请求了
2xx:处理成功,比如200表示正常,请求完成;204表示正常无响应等
3xx:重定向
4xx:客户端出现错误,比如著名的404找不到
5xx:服务器出现错误 ,比如500的内部错误


res.encoding='utf-8'
print(res.text)


<!DOCTYPE html>
<!--STATUS OK-->
<html> 
<head>
<meta http-equiv=content-type content=text/html;charset=utf-8>
<meta http-equiv=X-UA-Compatible content=IE=Edge>
<meta content=always name=referrer>
<link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css>
<title>百度一下,你就知道</title>
</head> 
<body link=#0000cc>
 <div id=wrapper>
 <div id=head> 
<div class=head_wrapper> 
<div class=s_form>
 <div class=s_form_wrapper> 
<div id=lg>
 <img hidefocus=true src=//www.baidu.com/img/bd_logo1.jpg width=270 height=129> 
</div> 
<form id=form name=f action=//www.baidu.com/s class=fm>
 <input type=hidden name=bdorz_come value=1> 
<input type=hidden name=ie value=utf-8>
 <input type=hidden name=f value=8> 
<input type=hidden name=rsv_bp value=1>
 <input type=hidden name=rsv_idx value=1> 
<input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=w
d class=s_ipt value maxlength=255 autocomplete=off autofocus></span>
<span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> 
</form>
 </div> 
</div>
 <div id=u1> 
<a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> 
<a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> 
<a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> 
<a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> 
<noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript>
 <script>
document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === " rel="external nofollow"  rel="external nofollow"  rel="external nofollow" " ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');
</script>
 <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> 
</div> 
</div>
 </div> 
<div id=ftCon>
 <div id=ftConw>
 <p id=lh> 
<a href=http://home.baidu.com>关于百度</a> 
<a href=http://ir.baidu.com>About Baidu</a> 
</p> 
<p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; 
<a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> 
</p> 
</div>
 </div> 
</div> 
</body>
 </html>

主要的点

(1).用get请求得到的数据是一个response对象,用response.text属性来查看。
(2).修改编码形式用response.encoding='utf-8/gbk/...'encoding是它的一个属性可以查看response.encoding


res.encoding
>>>:
>'utf-8'

(3).无论响应是文本还是二进制内容,我们都可以用content属性获得bytes对象:


import requests
url='http://www.baidu.com'
res = requests.get(url)
print(res.content)
print("----------")
print(res.text)
print("----------")
print(type(res))

<!DOCTYPE html>\r\n<!--STATUS OK-->
<html> 
<head>
<meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>\xe7\x99\xbe\xe5\xba\xa6\xe4\xb8\x80\xe4\xb8\x8b\xef\xbc\x8c\xe4\xbd\xa0\xe5\xb0\xb1\xe7\x9f\xa5\xe9\x81\x93</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.jpg width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=\xe7\x99\xbe\xe5\xba\xa6\xe4\xb8\x80\xe4\xb8\x8b class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>\xe6\x96\xb0\xe9\x97\xbb</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>\xe5\x9c\xb0\xe5\x9b\xbe</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>\xe8\xa7\x86\xe9\xa2\x91</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>\xe8\xb4\xb4\xe5\x90\xa7</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>\xe7\x99\xbb\xe5\xbd\x95</a> </noscript> <script>document.write(\'<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=\'+ encodeURIComponent(window.location.href+ (window.location.search === " rel="external nofollow" " ? "?" : "&")+ "bdorz_come=1")+ \'" name="tj_login" class="lb">\xe7\x99\xbb\xe5\xbd\x95</a>\');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">\xe6\x9b\xb4\xe5\xa4\x9a\xe4\xba\xa7\xe5\x93\x81</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>\xe5\x85\xb3\xe4\xba\x8e\xe7\x99\xbe\xe5\xba\xa6</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>\xe4\xbd\xbf\xe7\x94\xa8\xe7\x99\xbe\xe5\xba\xa6\xe5\x89\x8d\xe5\xbf\x85\xe8\xaf\xbb</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>\xe6\x84\x8f\xe8\xa7\x81\xe5\x8f\x8d\xe9\xa6\x88</a>&nbsp;\xe4\xba\xacICP\xe8\xaf\x81030173\xe5\x8f\xb7&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>\r\n'
----------
<!DOCTYPE html>
<!--STATUS OK-->
<html>
<head>
<meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge>
<meta content=always name=referrer>
<link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css>
<title>ç™¾åº¦ä¸€ä¸‹ï¼Œä½ å°±çŸ¥é“</title><
/head> <body link=#0000cc> <div id=wrapper> 
<div id=head>
<div class=head_wrapper> <div class=s_form> 
<div class=s_form_wrapper> 
<div id=lg> 
<img hidefocus=true src=//www.baidu.com/img/bd_logo1.jpg width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> 
<input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8>
<input type=hidden name=rsv_bp value=1> 
<input type=hidden name=rsv_idx value=1>
<input type=hidden name=tn value=baidu>
<span class="bg s_ipt_wr">
<input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr">
<input type=submit id=su value=百度一下 class="bg s_btn">
</span>
</form>
</div> 
</div>
<div id=u1> 
<a href=http://news.baidu.com name=tj_trnews class=mnav>æ–°é—»</a> 
<a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> 
<a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> 
<a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> 
<noscript> 
<a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a>
</noscript>
<script>
document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === " rel="external nofollow"  rel="external nofollow"  rel="external nofollow" " ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');
</script> 
<a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> 
</div>
</div>
</div> 
<div id=ftCon>
<div id=ftConw> 
<p id=lh> 
<a href=http://home.baidu.com>å³äºŽç™¾åº¦</a> 
<a href=http://ir.baidu.com>About Baidu</a>
</p>
<p id=cp>&copy;2017&nbsp;Baidu&nbsp;
<a href=http://www.baidu.com/duty/>使用百度前å¿è¯»</a>&nbsp;
<a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>
&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> 
</p> 
</div>
</div>
</div> 
</body> 
</html>
<class 'requests.models.Response'>

(4).status_code属性来查看该请求返回的状态码

2.带参数访问url

(1).带http 的头去访问可以传入参数:headers={'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit'} ,不至于很快就被判断惩恶爬虫,把你的IP给封了。
(2).Cookie


# 获得指定cookie
r.cookies['cookie_name']
# 传入cookie 用dict来传递
cs = {'token':'密码','status':'状态'}
res = requests.get(url, cookies='cs')

3).指定超时


res = requests.get(url, timeout=3) #3秒后超时

注意:一般用get方法就可以爬取一些比较简单容易的网站。

4.requests的一些常用方法和主要参数

方法 说明
requests.request() 构造一个请求,用于以下各种方法的处理
requests.get() 获取HTML网页的主要方法,对应于HTTP的GET
requests.head() 获取HTML网页头信息的方法,对应于HTTP的HEAD
requests.post() 向HTML提交POST请求的方法,对应于HTTP的POST
requests.put() 向HTML提交PUT请求的方法,对应于HTTP的PUT
requests.patch() 向HTML提交局部修改请求的方法,对应于HTTP的PATCH
requests.delete() 向HTML提交删除请求的方法,对应于HTTP的DELETE

requests.get()方法的参数:
格式:requests.get(url, params=None, **kwargs) 最前面介绍的几个常用的掌握就够用了。


#url:要访问的url地址
# params:url中的额外参数,可选的,字典或者字典或字节形式传递
# **kwargs:控制访问的参数,可选
## headers,timeout,cookies,data,JSON,proxies,allow_redirects,stream,veriftty,cert,files,auth

5.requests.Response对象的属性说明

属性 说明
res.status_code HTTP请求返回的状态码,200表示连接成功,404表示失败
res.text HTTP响应内容的字符串形式,即url对应的页面内容
res.encoding 从HTTP header中猜测的响应内容的编码形式,乱码可以修改防止乱码
res.content 从内容中分析出的响应内容的编码方式,备用
res.apparent_encoding HTTP响应内容的二进制形式

xpath简介

Xpath是一门在xml文档中查找信息的语言。Xpath可用来在xml文档中对元素和属性进行遍历。由于html的层次结构与xml的层次结构天然一致,所以使用Xpath也能够进行html元素的定位。

定位方法 1.绝对路径定位:

顾名思义,将Xpath表达式从html的最外层节点,逐层填写,最后定位到操作元素,一般浏览器插件出来都是绝对定位
类似:/html/body/div[1]/div[2]/div[5]/div[1]/div[1]/form/span[2]/input

2.相对路径定位

通过相对路径定位元素,提取的是元素的部分特征,只要提取恰当,能够保证版本间稳定,是进行自动化测试的首选。
类似://div[@class='e']/a/p/span/text() @后面是属性,最后的text()提取标签之间的文本数据

3.索引号定位

类似:/html/body/div[1]/div[2]/div[5]/div[1]/div[1]/form/span[last()-1]/input 表示form下倒数第二个span

4.属性定位

类似://*[@id=“kw” and @name=‘wd'] 表示 id 属性为 kw 且 name 属性为 wd

5.其它定位方法

还要别的定位方法,不常用,不介绍

lxml简介

导入lxml 的 etree 库


from lxml import etree

简单使用

(1).利用etree.HTML,将html字符串(bytes类型或str类型)转化为Element对象,Element对象具有xpath的方法,返回结果列表。


html = etree.HTML(text) 
ret_list = html.xpath("xpath语法规则字符串")

(2).xpath方法返回列表的三种情况

返回空列表:根据xpath语法规则字符串,没有定位到任何元素
返回由字符串构成的列表:xpath字符串规则匹配的一定是文本内容或某属性的值
返回由Element对象构成的列表:xpath规则字符串匹配的是标签,列表中的Element对象可以继续进行xpath

注意:

(1).lxml.etree.HTML(html_str)可以自动补全标签

(2).lxml.etree.tostring函数可以将转换为Element对象再转换回html字符串

(3).爬虫如果使用lxml来提取数据,应该以lxml.etree.tostring的返回结果作为提取数据的依据

实例:爬取51.job的大数据职业信息的第一页【requests+xpath】

分析:打开首页,搜索大数据,定位是兰州,F12调式查看,爬取工作名称和公司名就好了

51.job大数据页面地点定位兰州

定位

位置


job_name

cname


import requests
from lxml import etree
url = "https://search.51job.com/list/270200,000000,0000,00,9,99,%25E5%25A4%25A7%25E6%2595%25B0%25E6%258D%25AE,2,1.html?lang=c&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&ord_field=0&dibiaoid=0&line=&welfare="
header = {
    'User-Agent': 'Mozilla/5.0 (windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'
}
res = requests.get(url,headers=header)
res.encoding = "gbk"
#print(res.text)
data = etree.HTML(res.text)#加载成html树
job_name = data.xpath("//div[@class='e']/a/p/span/text()")
cname = data.xpath("/html/body/div[2]/div[3]/div/div[2]/div[4]/div[1]/div/div[2]/a/@title")

到此这篇关于python中requests库+xpath+lxml简单使用的文章就介绍到这了,更多相关requests库+xpath+lxml使用内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: python中requests库+xpath+lxml简单使用

本文链接: https://www.lsjlt.com/news/124928.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • python中requests库+xpath+lxml简单使用
    目录安装简单使用1.简单访问一个url:2.带参数访问url4.requests的一些常用方法和主要参数5.requests.Response对象的属性说明xpath简介lxml简介...
    99+
    2024-04-02
  • Python中Lxml与Xpath解析库如何使用
    本篇文章给大家分享的是有关Python中Lxml与Xpath解析库如何使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。一、xpath 概念、xpath节点、xpath语法、x...
    99+
    2023-06-15
  • Python HTTP库 requests 的简单使用详情
    目录1、简单使用2、构建请求查询参数3、构建请求头Headers4、构建POST请求数据 4.1 表单数据4.2 json数据5、获取响应内容6、Cookies7、超时配置8、代理r...
    99+
    2024-04-02
  • Python使用lxml解析xpath爬取konachan
    要使用lxml解析xpath来爬取konachan,你可以按照以下步骤进行:1. 首先,确保你已经安装了lxml库。你可以使用以下命...
    99+
    2023-08-22
    Python
  • python爬虫-简单使用xpath下载
      首先 1.为方便以下进行       谷歌浏览器里要安装xpath脚本  2.下载一个lmxl     命令:pip install lxml 3. 以下三张图是一个,当时爬的 《糗事百科》里的图片   值的注意的是:在爬取接口时,要...
    99+
    2023-01-30
    爬虫 简单 python
  • Python中requests库怎么使用
    这篇文章主要介绍了Python中requests库怎么使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Python中requests库怎么使用文章都会有所收获,下面我们一起来看看吧。一、requests库re...
    99+
    2023-06-30
  • python 网页解析器掌握第三方 lxml 扩展库与 xpath 的使用方法
    今天说的则是使用另外一种扩展库 lxml 来对网页完成解析。同样的,lxml 库能完成对 html、xml 格式的文件解析,并且能够用来解析大型的文档、解析速度也是相对比较快的。 要...
    99+
    2024-04-02
  • python网页解析器掌握第三方lxml扩展库与xpath的使用示例
    这篇文章将为大家详细讲解有关python网页解析器掌握第三方lxml扩展库与xpath的使用示例,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。1、导入 lxml 扩展库、并创建对象# -*-&n...
    99+
    2023-06-14
  • python中turtle库的简单使用教程
    Turtle库是Python中的一个绘图库,它可以在画布上绘制各种形状和图案。下面是一个简单的使用教程:1. 导入turtle库:在...
    99+
    2023-08-17
    Python
  • python random库的简单使用demo
    目录python random库简单使用demopython random库简单使用demo 当我们需要生成随机数或者从一个序列中随机选择元素时,可以使用 Python 内置的 r...
    99+
    2023-03-24
    python random库 python random
  • Python操作lxml库之基础使用篇
    目录一、lxml库概述1、lxml库介绍2、lxml库特点3、lxml库的安装二、基本使用1、lxml.etree2、解析HTML网页3、读取并解析HTML文件三、lxml使用流程1...
    99+
    2022-12-23
    python操作lxml库 python lxml库
  • python中requests库安装与使用详解
    目录前言1、Requests介绍2、requests库的安装3、requests库常用的方法4、response对象的常用属性5、使用requests发送get请求5.1  ...
    99+
    2024-04-02
  • Python定时库Apscheduler的简单使用
            在Python中需要执行定时任务,可以使用Apscheduler。   &n...
    99+
    2024-04-02
  • python爬虫之pyppeteer库简单使用
    pyppeteer 介绍Pyppeteer之前先说一下Puppeteer,Puppeteer是谷歌出品的一款基于Node.js开发的一款工具,主要是用来操纵Chrome浏览器的 AP...
    99+
    2024-04-02
  • Python爬虫Requests库如何使用
    本篇内容主要讲解“Python爬虫Requests库如何使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python爬虫Requests库如何使用”吧!1、安装 requests 库因为学习过...
    99+
    2023-07-06
  • Python 文档解析lxml库的使用详解
    目录1.lxml库简介2.lxml库方法介绍3.代码实例1.lxml库简介 lxml 是 Python 常用的文档解析库,能够高效地解析 HTML/XML 文档,常用于 Python...
    99+
    2024-04-02
  • Python爬虫Requests库的使用详情
    目录一、Requests库的7个主要的方法二、Response对象的属性三、爬取网页通用代码四、Resquests库的常见异常五、Robots协议展示六、案例展示一、Requests...
    99+
    2024-04-02
  • Python中requests库的用法详解
    目录一、requests库安装请求响应二、发送get请求1、一个带参数的get请求:2、响应json3、添加头信息headers4、添加和获取cookie信息三、发送post请求1、...
    99+
    2024-04-02
  • python爬虫中requests库怎么用
    小编给大家分享一下python爬虫中requests库怎么用,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!python爬虫—requests库的用法request...
    99+
    2023-06-25
  • Python简单使用InfluxDB
    之前已经在自己的MQTT服务器上安装好了InfluxDB时序数据库,接下来写个Python程序测试下. API详情参阅这里 打开powershell,执行pip install influxdb安装模块 程序API详细参考这...
    99+
    2023-01-31
    简单 Python InfluxDB
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作