![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
爬虫学习
Eniac-W
这个作者很懒,什么都没留下…
展开
-
数据提取(三):xpath -在lxml中使用xpath语法以获取标签、属性、内容
hello.html<html><body> <div> <ul> <li class="item-0"><a href="link1.html">first item</a></li> <li class="item-1"><a href="link2.html">second item</a><原创 2020-11-25 13:35:24 · 4887 阅读 · 0 评论 -
数据提取(二):xpath - lxml从字符串和文件中解析html代码 etree.html(),etree.tostring(),etree.parse(),etree.HTMLParser()
一、lxml库简述lxml库是一个HTML、XML的解析器,主要功能是如何解析和提取HTML、XML数据。它和正则一样是用 C 实现的,是一款高性能的 Python HTML/XML 解析器,可以利用之前学习的XPath语法,来快速的定位特定元素以及节点信息。lxml python 官方文档:http://lxml.de/index.html需要安装C语言库,可使用 pip 安装:pip install lxml二、lxml库的基本使用(1)从字符串中解析HTML代码:etree.html(str原创 2020-11-24 17:50:01 · 5955 阅读 · 3 评论 -
数据提取(一):Xpath - 语法
一、Xpath简述:https://www.runoob.com/xpath/xpath-intro.htmlxpath(XML Path Language)是一门在XML、HTML文档中查找信息的语言,可用来在XML HTML文档中对元素和属性进行遍历二、Xpath Helper简述:https://www.cnblogs.com/tinghai8/p/9552539.htmlxPath helper 是xpath的开发工具,是一款 Chrome 浏览器的开发者插件/Firefox插件为Try Xp原创 2020-11-24 14:31:33 · 580 阅读 · 0 评论 -
requests库(一):
安装 pip install requests官方文档 http://docs.python-requests.org/zh-CN/latest/index.html官方中文文档https://requests.readthedocs.io/zh_CN/latest/github地址:http://github.com/requests/requests还可以在pycharm中安装第三方库 file->settings->project->+...原创 2020-11-20 23:16:50 · 144 阅读 · 1 评论 -
cookie(一)http.cookiejar模块:两种方法实现模拟登录、cookie本地保存和加载
一、cookie基本概念介绍二、cookie模拟登录""""访问一个需要登录的网站需要加入cookie在headers中以访问知乎热榜https://www.zhihu.com/hot为例不登录无法访问热榜的内容 :从程序控制台输出的网页内容中ctrl+F查找网页中复制的内容 发现找不到,即使我们在headers中加了User-Agent也访问不了热榜内容解决方法一: headers中加入从https://www.zhihu.com/hot网页复制的cookie 注意仅仅在 hea原创 2020-11-20 17:53:13 · 3326 阅读 · 0 评论 -
urllib库(三)parse模块:quote()/quote_plus(),unquote()/unquote_plus(),quote_from_bytes()
y原创 2020-11-19 15:15:24 · 11758 阅读 · 0 评论 -
urllib库(二)parse模块:urlparse()/urlsplit(),parse_qs()/parse_qsl(),urlunparse()/urlunsplit(),urlencode()
tt原创 2020-11-18 21:39:29 · 2020 阅读 · 0 评论 -
urllib库(一)request模块:urlopen(),Request() 实现 get/post,urlretrieve() 下载网页文件,ProxyHandler()设置代理
一、urllib库python3内置的urllib库不需要安装直接import导入该库中主要模块有:urllib.request:用来打开和读取URL,是一个请求模块urllib.error:包含了urllib.request产生的异常,是一个异常处理模块urllib.parse:用来解析和处理URL,是一个解析模块urllib.robotparse:用来解析页面的robots.txturllib.response:响应模块>>> help(urllib)Help on原创 2020-11-18 00:07:32 · 1608 阅读 · 1 评论 -
HTTP简述(一):URL解析、请求方法post/get、请求头参数、响应码,chrome抓包工具
一原创 2020-11-15 13:32:46 · 2930 阅读 · 0 评论