爬虫
jason3586596
这个作者很懒,什么都没留下…
展开
-
lxml结合xpath注意事项
1.使用Xpath语法,应该使用Element.xpath方法,来执行xpath选择,示例代码如下: trs = html.xpath("//tr[position()>2]") xpath函数返回的永远是一个列表 2.获取某个标签的属性: href = html.xpath("//a/@href") 3.获取文本 , 通过xpath下的text()函数: address = tr.xpath("./td[4]/text()")[0] 4.在某个标签下使用xpath函数 , 获取其子孙函数, 应原创 2020-07-19 13:48:47 · 231 阅读 · 0 评论 -
P20【数据解析】1-xpath简介以及工具安装
XPath语法和lxml模块 什么是XPath? xpath (xml path language)是一门xml 和html文档中查找信息的语言,可以用来在xml和html中对元素和属性进行遍历 XPath开发工具 Chrome插件 XPath Helper Firefox插件 XPath Checker 选取节点 XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。 下面列出了最有用的路径表达式: 表达...翻译 2020-07-07 21:08:18 · 155 阅读 · 0 评论 -
requests库
requests库 虽然Python的标准库中 urllib模块已经包含了平常我们使用的大多数功能,但是它的 API 使用起来让人感觉不太好,而 Requests宣传是 “HTTP for Humans”,说明使用更简洁方便。 文档地址: 利用pip可以非常方便的安装: pip install requests 发送GET请求: 最简单的发送get请求就是通过requests.get来调用: response = requests.get("http://www.baidu.com/") .转载 2020-07-07 20:58:54 · 127 阅读 · 0 评论 -
P18【网络请求】15-requests处理cookie信息
#encoding: utf-8 import requests # response = requests.get('https://www.baidu.com/') # print(response.cookies.get_dict()) url = "http://www.renren.com/PLogin.do" data = { 'email': "xxxxxxxxx@qq.com", 'password': "xxxxxxxxx"} headers = { ...转载 2020-07-07 20:05:36 · 1216 阅读 · 1 评论 -
网络爬虫-课时21剖析分页信息
网络学习笔记 import requests res = requests.get('http://api.roll.news.sina.com.cn/zt_list?channel=news&cat_1=gnxw&cat_2==gdxw1||=gatxw||=zs-pl||=mtjj&level==1||=2&show_ext=1&show_all=1...原创 2018-08-28 22:17:25 · 152 阅读 · 0 评论 -
网络爬虫-课时9抓取新闻内文页面
import requests from bs4 import BeautifulSoup res = requests.get('http://news.sina.com.cn/c/nd/2016-08-20/doc-ifxvctcc8121090.shtml') res.encoding = 'utf-8' print(res.text) soup = BeautifulSoup(res.te...原创 2018-06-30 10:18:52 · 386 阅读 · 0 评论 -
网络爬虫-课时5 用BeautifulSoup 剖析网页元素
打开运行,输入jupyter booknew(新建) python3import requestsres = requests.get('http://news.sina.com.cn/')res.encoding = 'utf-8'#print (res.text)from bs4 import BeautifulSouphtml_sample = ' \<html> \ <b...原创 2018-06-28 21:14:40 · 198 阅读 · 0 评论 -
网络爬虫-课时15抓取新闻评论数
import requests commments = requests.get('http://comment5.news.sina.com.cn/page/info?version=1&format=js&channel=gn&newsid=comos-fxvctcc8121090&group=&compress=0&ie=utf-8&o...原创 2018-07-01 11:49:09 · 478 阅读 · 0 评论 -
网络爬虫-课时18信息抽取函式
来自网络学习笔记原创 2018-07-01 11:46:13 · 205 阅读 · 0 评论