爬虫
文章平均质量分 91
Denrusn
这个作者很懒,什么都没留下…
展开
-
NumPy
NumPynumpy是python科学计算的基础包,是一个python库,提供多维数组对象,各自派生对象(如掩码数组和矩阵),及用于数组快速操作的各种API,有包括数字,逻辑,形状操作,排序,选择,输入输出,离散傅里叶变换,基本线性代数,基本统计运算和随机模拟等等。import numpy as np # 生成一个对角矩阵 np.eye(4) # array([[1., 0., 0., 0.], # [0., 1., 0., 0.], # [0., 0., 1., 0.原创 2020-08-14 11:43:21 · 290 阅读 · 0 评论 -
Beautiful Soup
Beautiful SoupBeautiful Soup有多个解析器如下:解析器使用方法优势劣势Python标准库BeautifulSoup(markup, “html.parser”)Python的内置标准库 执行速度适中 文档容错能力强Python 2.7.3 or 3.2.2)前 的版本中文档容错能力差lxml HTML 解析器BeautifulSoup(markup, “lxml”)速度快 文档容错能力强需要安装C语言库lxml XML 解析器B原创 2020-08-14 11:40:50 · 152 阅读 · 0 评论 -
XPath学习
XPath# 常用的方法 # 字符串格式的html文本的情况下 # 使用etree.HTML()方法把text转化成xpath对象 html = etree.HTML(text) # html文本以文件的形式存在时,使用etree.parse()解析html文件,转化成xpath对象 html = etree.parse('./test.html', etree.HTMLParser()) # 把xpath对象转化为bytes类型 result = etree.tostring(html)原创 2020-08-14 11:38:45 · 242 阅读 · 0 评论 -
正则表达式入门学习
正则表达式贪婪与非贪婪使用.*的时候,会尽可能的匹配更多的字符,导致有时候取到的字符并不是我们想要的。这就是贪婪模式。如以下代买,想要获取content内的数字1234567import re content = 'Hello 1234567 World_This is a Regex Demo' result = re.match('^He.*(\d+).*Demo$', content) print(result) print(result.group(1)) -----------原创 2020-08-14 11:36:28 · 160 阅读 · 0 评论 -
Requests爬虫学习(比较全面)
Requestsget请求# get请求 import requests data = { 'name': 'germey', 'age': 22 } r = requests.get('http://httpbin.org/get', params=data) print(r.text) # 返回JSON格式字符串转化的字典dict print(r.json()) print(type(r.json())) # dict 抓取网页import requ原创 2020-08-14 11:34:31 · 424 阅读 · 0 评论 -
urllib爬虫入门库
Urlliburllib有四大模块:request,error,parse,robotparser。request:http请求模块。error:异常处理模块。parse:工具模块,用来处理URL。robotparser:识别robots.txt判断哪些网站可以爬取。requesturlopen()方法,该方法返回的是一个HTTPResposne对象。参数: 【url】要爬取的网页地址 string【data】请求要传递的参数 bytes【timeout】用于设置超时时间,以秒为原创 2020-08-14 11:30:57 · 170 阅读 · 0 评论 -
爬虫入门
入门案例通过入门案例快速入门import requestsurl = 'http://www.cntour.cn/'strhtml = requests.get(url)print(strhtml.text)# --------------------------------------------------------------------import requestsimport jsondef get_translate_data(word=None): ur原创 2020-08-13 10:49:31 · 172 阅读 · 0 评论
分享