当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 0

cjh0613/blog
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
分享:有关Python爬虫.html 42.72 KB
一键复制 编辑 原始数据 按行查看 历史
cjh0613 提交于 2021-08-17 09:02 . 更新网站 2021-08-17 09:01
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="renderer" content="webkit"><meta name="force-rendering" content="webkit"><!----><script src="//cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script><script src="https://cdn.staticfile.org/layer/3.1.1/layer.min.js"></script><script src="/anti-selfish-browser/Browser.js"></script><script src="/anti-selfish-browser/anti-selfish-browser.js"></script><!----><meta name="format-detection" content="telephone=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="icon" href="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg?v=1.7.0" type="image/png" sizes="16x16"><link rel="icon" href="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg?v=1.7.0" type="image/png" sizes="32x32"><link rel="apple-touch-icon" href="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg?v=1.7.0" sizes="180x180"><link rel="mask-icon" href="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg?v=1.7.0" color="#54bcff"><meta name="msapplication-TileImage" content="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg"><meta name="msapplication-TileColor" content="#000000"><meta name="google-site-verification" content="WENVxYJ4LorKjirCAv6WnZEiM9vyEiZKmRIqaiTLOVw"><meta name="msvalidate.01" content="1995BB61A214C11B83C059025081A00C"><meta name="description" content="爬虫是什么? 网络爬虫是一种按照一定的规则自动地抓取网络信息的程序或者脚本。简单来说,网络爬虫就是根据一定的算法实现编程开发,主要通过URL实现数据的抓取和发掘。">
<meta property="og:type" content="article">
<meta property="og:title" content="分享:有关Python爬虫">
<meta property="og:url" content="https://cjh0613.com/%E5%88%86%E4%BA%AB%EF%BC%9A%E6%9C%89%E5%85%B3Python%E7%88%AC%E8%99%AB.html">
<meta property="og:site_name" content="峡州仙士之页">
<meta property="og:description" content="爬虫是什么? 网络爬虫是一种按照一定的规则自动地抓取网络信息的程序或者脚本。简单来说,网络爬虫就是根据一定的算法实现编程开发,主要通过URL实现数据的抓取和发掘。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-02-26T16:00:00.000Z">
<meta property="article:modified_time" content="2020-08-01T15:04:21.351Z">
<meta property="article:author" content="峡州仙士">
<meta property="article:tag" content="python">
<meta property="article:tag" content="建议">
<meta property="article:tag" content="爬虫">
<meta property="article:tag" content="教程">
<meta name="twitter:card" content="summary"><meta name="keywords" content="峡州仙士, 峡州仙士之页"><title>分享:有关Python爬虫 | 峡州仙士之页</title><link ref="canonical" href="https://cjh0613.com/%E5%88%86%E4%BA%AB%EF%BC%9A%E6%9C%89%E5%85%B3Python%E7%88%AC%E8%99%AB.html"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="//cdn.staticfile.org/font-awesome/5.12.1/css/all.min.css" type="text/css"><link rel="stylesheet" href="//cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" type="text/css"><link rel="stylesheet" href="//cdn.staticfile.org/social-share.js/1.0.16/css/share.min.css" type="text/css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/css/index.css?v=1.7.0"><link rel="dns-prefetch" href="https://www.googletagmanager.com"><link rel="dns-prefetch" href="https://hm.baidu.com"><script src="https://www.googletagmanager.com/gtag/js?id=UA-168599388-1" async></script><script>if (window.location.hostname !== 'localhost') {
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-168599388-1');
}</script><script>var _hmt = _hmt || [];
(function() {
var hm = document.createElement('script');
hm.src = 'https://hm.baidu.com/hm.js?3571f7725019f0e61870427684c3ce17';
hm.async = true;
if (false) {
hm.setAttribute('data-pjax', '');
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();</script><script>var Stun = window.Stun || {};
var CONFIG = {
root: '/',
algolia: undefined,
fontIcon: {"prompt":{"success":"fas fa-check-circle","info":"fas fa-arrow-circle-right","warning":"fas fa-exclamation-circle","error":"fas fa-times-circle"},"copyBtn":"fas fa-copy"},
sidebar: {"offsetTop":"20px","tocMaxDepth":6},
header: {"enable":true,"showOnPost":true,"scrollDownIcon":false},
post_widget: {"end_text":true},
night_mode: {"enable":true},
back2top: {"enable":true},
codeblock: {"style":"default","highlight":"light","word_wrap":false},
reward: true,
fancybox: true,
zoom_image: {"enable":true,"mask_color":"rgba(0,0,0,0.6)"},
gallery_waterfall: {"enable":true,"col_width":"220px","gap_x":"10px","gap_y":"10px"},
lazyload: {"enable":true,"placeholder":"gif"},
pjax: undefined,
external_link: {"icon":{"enable":true,"name":"fas fa-external-link-alt"}},
shortcuts: undefined,
prompt: {"copy_button":"复制","copy_success":"复制成功","copy_error":"复制失败"},
sourcePath: {"js":"js","css":"css","images":"images"},
};
window.CONFIG = CONFIG;</script><meta name="generator" content="Hexo 4.2.0"></head><body><div class="container" id="container"><header class="header" id="header"><div class="header-inner"><nav class="header-nav header-nav--fixed"><div class="header-nav-inner"><div class="header-nav-menubtn"><i class="fas fa-bars"></i></div><div class="header-nav-menu"><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/"><span class="header-nav-menu-item__icon"><i class="fas fa-home"></i></span><span class="header-nav-menu-item__text">首页</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/archives/"><span class="header-nav-menu-item__icon"><i class="fas fa-folder-open"></i></span><span class="header-nav-menu-item__text">归档</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/categories/"><span class="header-nav-menu-item__icon"><i class="fas fa-layer-group"></i></span><span class="header-nav-menu-item__text">分类</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/tags/"><span class="header-nav-menu-item__icon"><i class="fas fa-tags"></i></span><span class="header-nav-menu-item__text">标签</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="https://en.cjh0613.com/" target="_blank" rel="noopener"><span class="header-nav-menu-item__icon"><i class="fas fa-language"></i></span><span class="header-nav-menu-item__text">En</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="javascript:;" onclick="return false;"><span class="header-nav-menu-item__icon"><i class="fas fa-ellipsis-h"></i></span><span class="header-nav-menu-item__text">其他菜单项</span></a><div class="header-nav-submenu"><div class="header-nav-submenu-item"><a class="header-nav-submenu-item__link" href="/about.html"><span class="header-nav-submenu-item__icon"><i class="fas fa-user"></i></span><span class="header-nav-submenu-item__text">关于我</span></a></div><div class="header-nav-submenu-item"><a class="header-nav-submenu-item__link" href="/hot.html"><span class="header-nav-submenu-item__icon"><i class="fas fa-paper-plane"></i></span><span class="header-nav-submenu-item__text">热门文章</span></a></div><div class="header-nav-submenu-item"><a class="header-nav-submenu-item__link" href="https://suiji.cjh0613.com/" target="_blank" rel="external nofollow noopener noreferrer"><span class="header-nav-submenu-item__icon"><i class="fas fa-history"></i></span><span class="header-nav-submenu-item__text">随记</span></a></div><div class="header-nav-submenu-item"><a class="header-nav-submenu-item__link" href="/ask.html"><span class="header-nav-submenu-item__icon"><i class="fas fa-question"></i></span><span class="header-nav-submenu-item__text">留言/提问</span></a></div><div class="header-nav-submenu-item"><a class="header-nav-submenu-item__link" href="/friends/"><span class="header-nav-submenu-item__icon"><i class="fas fa-users"></i></span><span class="header-nav-submenu-item__text">朋友</span></a></div></div></div></div><div class="header-nav-search"><span class="header-nav-search__icon"><i class="fas fa-search"></i></span><span class="header-nav-search__text">搜索</span></div><div class="header-nav-mode"><div class="mode"><div class="mode-track"><span class="mode-track-moon"></span><span class="mode-track-sun"></span></div><div class="mode-thumb"></div></div></div></div></nav><div class="header-banner"><div class="header-banner-info"><div class="header-banner-info__title">世上本没有路</div><div class="header-banner-info__subtitle">峡州仙士之页</div><!--br--><!--div.header-banner-info__btn--></div><div class="cjh-btn"><div class="cjh-btn__icon"><a class="cjh-btn-a" href="/index.html" target="_blank" rel="noopener">移步首页</a></div></div></div></div></header><main class="main" id="main"><div class="main-inner"><div class="content-wrap" id="content-wrap"><div class="content" id="content"><!-- Just used to judge whether it is an article page--><div id="is-post"></div><div class="post"><header class="post-header"><h1 class="post-title">分享:有关Python爬虫</h1><div class="post-meta"><span class="post-meta-item post-meta-item--createtime"><span class="post-meta-item__icon"><i class="far fa-calendar-plus"></i></span><span class="post-meta-item__info">发表</span><span class="post-meta-item__value">2020-02-27</span></span><span class="post-meta-item post-meta-item--updatetime"><span class="post-meta-item__icon"><i class="far fa-calendar-check"></i></span><span class="post-meta-item__info">更新</span><span class="post-meta-item__value">2020-08-01</span></span><span class="post-meta-item post-meta-item--wordcount"><span class="post-meta-item__icon"><i class="far fa-file-word"></i></span><span class="post-meta-item__info">字数</span><span class="post-meta-item__value">917</span></span><span class="post-meta-item post-meta-item--readtime"><span class="post-meta-item__icon"><i class="far fa-clock"></i></span><span class="post-meta-item__info">预计阅读时长</span><span class="post-meta-item__value">4分</span></span><span class="post-meta-item post-meta-item--visitors"><span class="post-meta-item__icon"><i class="fas fa-eye"></i></span><span class="post-meta-item__info">阅读次数</span><span class="post-meta-item__value" id="busuanzi_value_page_pv"></span></span></div><div class="post-tags"><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/python/">python</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/建议/">建议</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/爬虫/">爬虫</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/教程/">教程</a></span></div></header><div class="post-body">
<h1 id="爬虫是什么">
<span class="heading-link">爬虫是什么?</span>
</h1>
<p>网络爬虫是一种按照一定的规则自动地抓取网络信息的程序或者脚本。简单来说,网络爬虫就是根据一定的算法实现编程开发,主要通过URL实现数据的抓取和发掘。</p>
<a id="more"></a>
<p>随着大数据时代的发展,数据规模越来越庞大,数据类型繁多,但是数据价值普遍较低。<br>
为了从庞大的数据体系里获取有价值的数据,从而延伸了网络爬虫、数据分析等多个职位。近几年,网络爬虫的需求更是井喷式地爆发,在招聘的供求市场上往往是供不应求,造成这个现状的主要原因就是求职者的专业水平低于需求企业的要求。<br>
传统的爬虫有百度、Google、必应等搜索引擎,这类通用的搜索引擎都有自己的核心算法。<br>
但是,通用的搜索引擎存在着一定的局限性:</p>
<p>(1)不同的搜索引擎对于同一个搜索会有不同的结果,搜索出来的结果未必是用户需要的信息。</p>
<p>(2)通用的搜索引擎扩大了网络覆盖率,但有限的搜索引擎服务器资源与无限的网络数据资源之间的矛盾将进一步加深。</p>
<p>(3)随着网络上数据形式繁多和网络技术的不断发展,图片、数据库、音频、视频多媒体等不同数据大量出现,通用搜索引擎往往对这些信息含量密集且具有一定结构的数据无能为力,不能很好地发现和获取。</p>
<p>因此,为了得到准确的数据,定向抓取相关网页资源的聚焦爬虫应运而生。聚焦爬虫是一个自动下载网页的程序,可根据设定的抓取目标有目的性地访问互联网上的网页与相关的URL,从而获取所需要的信息。与通用爬虫不同,聚焦爬虫并不追求全面的覆盖率,而是抓取与某一特定内容相关的网页,为面向特定的用户提供准备数据资源。</p>
<h1 id="学习基础">
<span class="heading-link">学习基础</span>
</h1>
<h2 id="http协议">
<span class="heading-link">HTTP协议</span>
</h2>
<p>不多说</p>
<h2 id="python基础">
<span class="heading-link">python基础</span>
</h2>
<p>不多说</p>
<p>可自行找网课,或按下一行链接学习</p>
<p>可参考(现查):<span class="exturl"><a class="exturl__link" href="https://www.runoob.com/python3" target="_blank" rel="external nofollow noopener noreferrer">https://www.runoob.com/python3</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span></p>
<h2 id="javascript">
<span class="heading-link">JavaScript</span>
</h2>
<p>涉及不多,不多说</p>
<h2 id="html">
<span class="heading-link">html</span>
</h2>
<p>简单识读,及使用浏览器开发者工具,不多说</p>
<p>可参考(现查):<span class="exturl"><a class="exturl__link" href="https://www.runoob.com/html/html-tutorial.html" target="_blank" rel="external nofollow noopener noreferrer">https://www.runoob.com/html/html-tutorial.html</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span></p>
<h2 id="excel处理">
<span class="heading-link">excel处理</span>
</h2>
<p>图形化软件,不多说</p>
<h1 id="python库">
<span class="heading-link">python库</span>
</h1>
<h2 id="爬虫库requests">
<span class="heading-link">爬虫库Requests</span>
</h2>
<p>Requests是Python的一个很实用的HTTP客户端库,爬静态网页的利器,速度贼快,遇动态网页则见鬼</p>
<h2 id="网页操控库selenium">
<span class="heading-link">网页操控库selenium</span>
</h2>
<p>自动操控浏览器,当然支持动态网页,速度较慢,满足一般需求</p>
<h2 id="手机app数据爬取appium">
<span class="heading-link">手机App数据爬取appium</span>
</h2>
<p>类似selenium,操控手机,进行数据爬取</p>
<h2 id="数据提取库beautifulsoup">
<span class="heading-link">数据提取库beautifulsoup</span>
</h2>
<p>前面的都是获取全部数据,这个是进行数据提取,挖出我们需要的数据</p>
<h2 id="数据excel处理库openpyxl">
<span class="heading-link">数据excel处理库openpyxl</span>
</h2>
<p>数据保存及加工</p>
<h2 id="爬虫框架scrapy">
<span class="heading-link">爬虫框架Scrapy</span>
</h2>
<p>小规模,数据量小,爬取速度不敏感,爬取网页玩转网页,用Requests库<br>
中规模,数据规模较大,爬取速度敏感,爬取网站、爬取系列网站,Scrapy库<br>
大规模,搜索引擎爬取,速度关键,用Requests库定制开发</p>
<h2 id="强大的数据处理库pandas">
<span class="heading-link">强大的数据处理库pandas</span>
</h2>
<p>不多说</p>
<h2 id="强大的字符串处理库re">
<span class="heading-link">强大的字符串处理库re</span>
</h2>
<p>可用于数据提取,比beautifulsoup快,但是……不多说了</p>
</div><footer class="post-footer"><div class="post-ending ending"><div class="ending__text">------ 本文结束,感谢您的阅读 ------</div></div><div class="post-copyright copyright"><div class="copyright-author"><span class="copyright-author__name">本文作者: </span><span class="copyright-author__value"><a href="https://cjh0613.com">峡州仙士</a></span></div><div class="copyright-link"><span class="copyright-link__name">原文链接: </span><span class="copyright-link__value"><a href="https://cjh0613.com/%E5%88%86%E4%BA%AB%EF%BC%9A%E6%9C%89%E5%85%B3Python%E7%88%AC%E8%99%AB.html">https://cjh0613.com/%E5%88%86%E4%BA%AB%EF%BC%9A%E6%9C%89%E5%85%B3Python%E7%88%AC%E8%99%AB.html</a></span></div><div class="copyright-notice"><span class="copyright-notice__name">声明: </span><span class="copyright-notice__value">如文章有更新,将先在本网站(峡州仙士之页)发布!(可百度)| 本网站所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="external nofollow noopener noreferrer" target="_blank">BY-NC-SA</a> 许可协议。转载请注明出处!</span></div></div><div class="post-tags"><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/python/">python</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/建议/">建议</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/爬虫/">爬虫</a></span><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="tags/教程/">教程</a></span></div><div class="post-share"><div class="social-share" data-sites="qzone, qq, weibo, wechat, douban, linkedin, facebook, twitter, google">分享本文到: </div></div><div class="post-reward reward"><div class="reward-button">请我喝一杯凉虾~</div><div class="reward-qrcode"><a class="exturl__link" href="https://www.cjh0613.com/RedEnvelope" target="_blank" rel="external nofollow noopener noreferrer">(推荐)【免费打赏】手机用户点此一键领红包,您通过使用红包来支持站长</a><p>BTC地址(建议使用ETH):3F7hk94nnBHrL4LuHZdtP4soPCefCV6CbU</p><p>ETH收款地址:0x2AdDE524665af970acE4CB3D50dE70136c88f90F</p><span class="reward-qrcode-alipay"><img class="reward-qrcode-alipay__img" src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/pasted-5.png"><div class="reward-qrcode-alipay__text">支付宝打赏</div></span><span class="reward-qrcode-wechat"><img class="reward-qrcode-wechat__img" src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/pasted-6.png"><div class="reward-qrcode-wechat__text">微信打赏</div></span></div></div><nav class="post-paginator paginator"><div class="paginator-prev"><a class="paginator-prev__link" href="/The%20Book%20of%20Mozilla.html"><span class="paginator-prev__icon"><i class="fas fa-angle-left"></i></span><span class="paginator-prev__text">The Book of Mozilla</span></a></div><div class="paginator-next"><a class="paginator-next__link" href="/github%E7%BD%91%E7%9B%98%E8%BE%85%E5%8A%A9%E5%B7%A5%E5%85%B7.html"><span class="paginator-prev__text">github网盘辅助工具</span><span class="paginator-next__icon"><i class="fas fa-angle-right"></i></span></a></div></nav></footer></div></div><div class="comments" id="comments"><div id="waline-container"></div></div></div><div class="sidebar-wrap" id="sidebar-wrap"><aside class="sidebar" id="sidebar"><div class="sidebar-nav"><span class="sidebar-nav-toc current">文章目录</span><span class="sidebar-nav-ov">站点概览</span></div><section class="sidebar-toc"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#爬虫是什么"><span class="toc-number">1.</span> <span class="toc-text">
爬虫是什么?
</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#学习基础"><span class="toc-number">2.</span> <span class="toc-text">
学习基础
</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#http协议"><span class="toc-number">2.1.</span> <span class="toc-text">
HTTP协议
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#python基础"><span class="toc-number">2.2.</span> <span class="toc-text">
python基础
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#javascript"><span class="toc-number">2.3.</span> <span class="toc-text">
JavaScript
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#html"><span class="toc-number">2.4.</span> <span class="toc-text">
html
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#excel处理"><span class="toc-number">2.5.</span> <span class="toc-text">
excel处理
</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#python库"><span class="toc-number">3.</span> <span class="toc-text">
python库
</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#爬虫库requests"><span class="toc-number">3.1.</span> <span class="toc-text">
爬虫库Requests
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#网页操控库selenium"><span class="toc-number">3.2.</span> <span class="toc-text">
网页操控库selenium
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#手机app数据爬取appium"><span class="toc-number">3.3.</span> <span class="toc-text">
手机App数据爬取appium
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#数据提取库beautifulsoup"><span class="toc-number">3.4.</span> <span class="toc-text">
数据提取库beautifulsoup
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#数据excel处理库openpyxl"><span class="toc-number">3.5.</span> <span class="toc-text">
数据excel处理库openpyxl
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#爬虫框架scrapy"><span class="toc-number">3.6.</span> <span class="toc-text">
爬虫框架Scrapy
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#强大的数据处理库pandas"><span class="toc-number">3.7.</span> <span class="toc-text">
强大的数据处理库pandas
</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#强大的字符串处理库re"><span class="toc-number">3.8.</span> <span class="toc-text">
强大的字符串处理库re
</span></a></li></ol></li></ol></section><!-- ov = overview--><section class="sidebar-ov hide"><div class="sidebar-ov-author"><div class="sidebar-ov-author__avatar"><img class="sidebar-ov-author__avatar_img" src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/icons/CJHicon.jpg" alt="avatar"></div><p class="sidebar-ov-author__text">这里也有我的痕迹(按排序):</p></div><div class="sidebar-ov-social"><a class="sidebar-ov-social-item" href="/20200402RSS.html" target="_blank" rel="noopener" data-popover="RSS订阅" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fas fa-rss"></i></span></a><a class="sidebar-ov-social-item" href="https://github.com/cjh0613" target="_blank" rel="external nofollow noopener noreferrer" data-popover="Github" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fab fa-github"></i></span></a><a class="sidebar-ov-social-item" href="https://www.thingiverse.com/cjh0613" target="_blank" rel="external nofollow noopener noreferrer" data-popover="Thingiverse" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fas fa-cube"></i></span></a><a class="sidebar-ov-social-item" href="https://t.me/cjh0613" target="_blank" rel="external nofollow noopener noreferrer" data-popover="Telegram" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fab fa-telegram"></i></span></a><a class="sidebar-ov-social-item" href="https://www.quora.com/profile/Bruce-Chen-199" target="_blank" rel="external nofollow noopener noreferrer" data-popover="Quora" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fab fa-quora"></i></span></a><a class="sidebar-ov-social-item" href="https://www.zhihu.com/people/cjh0613" target="_blank" rel="external nofollow noopener noreferrer" data-popover="知乎" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fas fa-question"></i></span></a><a class="sidebar-ov-social-item" href="/about.html" target="_blank" rel="noopener" data-popover="更多" data-popover-pos="up"><span class="sidebar-ov-social-item__icon"><i class="fas fa-ellipsis-h"></i></span></a></div><div class="sidebar-ov-state"><a class="sidebar-ov-state-item sidebar-ov-state-item--posts" href="/archives/"><div class="sidebar-ov-state-item__count">102</div><div class="sidebar-ov-state-item__name">归档</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--categories" href="/categories/"><div class="sidebar-ov-state-item__count">6</div><div class="sidebar-ov-state-item__name">分类</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--tags" href="/tags/"><div class="sidebar-ov-state-item__count">66</div><div class="sidebar-ov-state-item__name">标签</div></a></div><div class="sidebar-ov-cc"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="external nofollow noopener noreferrer" data-popover="知识共享" data-popover-pos="up"><img src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/images/cc-by-nc-sa.svg"></a></div></section><div class="sidebar-reading"><div class="sidebar-reading-info"><span class="sidebar-reading-info__text">你已阅读了 </span><span class="sidebar-reading-info__num">0</span></div><div class="sidebar-reading-line"></div></div></aside></div><div class="clearfix"></div></div></main><footer class="footer" id="footer"><div class="footer-inner"><div><span>Copyright © 2020~2021</span><span class="footer__icon"><i class="fas fa-code"></i></span><span>峡州仙士</span><span class="footer__devider">|</span><span>粤ICP备12009483号(Gitee站)</span></div><!----><div class="busuanzi"><span class="busuanzi-siteuv"><span class="busuanzi-siteuv__icon"><i class="fas fa-user"></i></span><span class="busuanzi-siteuv__info">访问人数</span><span class="busuanzi-siteuv__value" id="busuanzi_value_site_uv"></span></span><span class="busuanzi-sitepv"><span class="busuanzi-siteuv__icon"><i class="fas fa-eye"></i></span><span class="busuanzi-siteuv__info">浏览总量</span><span class="busuanzi-siteuv__value" id="busuanzi_value_site_pv"></span></span></div><div>推荐使用电脑端访问本站</div><div class="webinfo-item"><span class="webinfo-runtime-name">本站持续运行时间 :</span><span class="webinfo-runtime-count" id="webinfo-runtime-count" start_date="2020/2/26 00:00:00"></span></div><div style="display:none"><script type="text/javascript" src="https://js.users.51.la/20667167.js"></script><script src="https://s96.cnzz.com/z_stat.php?id=1277785770&amp;web_id=1277785770"></script></div><div><p><a class="exturl__link" href="/20200402RSS.html" target="_blank" rel="noopener">RSS</a>&nbsp;|&nbsp;<a class="exturl__link" href="https://en.cjh0613.com/index.html" target="_blank" rel="noopener">English&emsp;I18N&emsp;国际站</a>&nbsp;|&nbsp;<a class="exturl__link" href="https://status.cjh0613.com/" target="_blank" rel="external nofollow noopener noreferrer">峡州仙士之页状态监控</a><br><a class="exturl__link" href="https://suyin-blog.club/" target="_blank" rel="noopener">苏寅</a>&nbsp;|&nbsp;<a class="exturl__link" href="https://www.avg.cx" target="_blank" rel="noopener">Yrh</a>&nbsp;|&nbsp;<a class="exturl__link" href="https://www.v6g.cn/" target="_blank" rel="noopener">微6g资源网</a><br><a class="exturl__link" href="https://cjh0613.com/archives/index.html" target="_blank" rel="noopener">归档页</a>&nbsp;|&nbsp;
sitemap(<a class="exturl__link" href="https://cjh0613.com/sitemap.xml" target="_blank" rel="noopener">1</a><a class="exturl__link" href="https://cjh0613.com/google-sitemap.xml" target="_blank" rel="noopener">2</a>
&nbsp;|&nbsp;<a class="exturl__link" href="/friends/index.html" target="_blank" rel="noopener">更多友情链接</a></p></div></div></footer><div class="loading-bar" id="loading-bar"><div class="loading-bar__progress"></div></div><div class="back2top" id="back2top"><span class="back2top__icon"><i class="fas fa-rocket"></i></span></div></div><div class="search-mask"></div><script>//var btn = document.getElementById("cjh_search");
function cjh_search(){
var $input = $('.search-input input');var q = $input.val().toLowerCase().trim();
var url = "https://www.baidu.com/s";
var url = url + '?wd='+q+' "峡州仙士之页"';
if(q){
var tempwindow=window.open('_blank');
tempwindow.location=url;
}}
function cjh_g_search(){
var $input = $('.search-input input');var q = $input.val().toLowerCase().trim();
var url = "https://www.sanzhima.com/search";
var url = url + '?q='+q+' site:cjh0613.com';
if(q){
var tempwindow=window.open('_blank');
tempwindow.location=url;
}}
</script><div class="search-popup"><span class="search-close"></span><div class="search-input"><input placeholder="搜索文章(支持多关键词,请用空格分隔)"><div class="cjh-btn__icon" style="font-size:1rem"><a class="cjh-btn-a" href="javascript:;" onclick="cjh_g_search();return false;">谷歌搜索</a>&emsp;<a class="cjh-btn-a" id="cjh_search" href="javascript:;" onclick="cjh_search();return false;">备用搜索</a></div><div style="text-align: center"><p>(您还可以在<a class="exturl__link" href="/blog/archives/" target="_blank" rel="noopener">归档页</a>搜索文章标题)</p></div></div><div class="search-results"></div></div><script src="//cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script><script src="//cdn.staticfile.org/velocity/1.5.2/velocity.min.js"></script><script src="//cdn.staticfile.org/velocity/1.5.2/velocity.ui.min.js"></script><script src="//cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js"></script><script src="//cdn.staticfile.org/masonry/4.2.2/masonry.pkgd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/lazyload.min.js"></script><script src="//cdn.staticfile.org/social-share.js/1.0.16/js/social-share.min.js"></script><script>function initSearch() {
var isXML = true;
var search_path = 'search.json';
if (!search_path) {
search_path = 'search.xml';
} else if (/json$/i.test(search_path)) {
isXML = false;
}
var path = '/' + search_path;
$.ajax({
url: path,
dataType: isXML ? 'xml' : 'json',
async: true,
success: function (res) {
var datas = isXML ? $('entry', res).map(function () {
// 将 XML 转为 JSON
return {
title: $('title', this).text(),
content: $('content', this).text(),
url: $('url', this).text()
};
}).get() : res;
var $input = $('.search-input input');
var $result = $('.search-results');
// 搜索对象(标题、内容)的权重,影响显示顺序
var WEIGHT = { title: 100, content: 1 };
var searchPost = function () {
var searchText = $input.val().toLowerCase().trim();
// 根据空白字符分隔关键字
var keywords = searchText.split(/[\s]+/);
// 搜索结果
var matchPosts = [];
// 有多个关键字时,将原文字整个保存下来
if (keywords.length > 1) {
keywords.push(searchText);
}
// 防止未输入字符时搜索
if (searchText.length > 0) {
datas.forEach(function (data) {
var isMatch = false;
// 没有标题的文章使用预设的 i18n 变量代替
var title = (data.title && data.title.trim()) || '[ 文章无标题 ]';
var titleLower = title && title.toLowerCase();
// 删除 HTML 标签 和 所有空白字符
var content = data.content && data.content.replace(/<[^>]+>/g, '');
var contentLower = content && content.toLowerCase();
// 删除重复的 /
var postURL = data.url && decodeURI(data.url).replace(/\/{2,}/g, '/');
// 标题中匹配到的关键词
var titleHitSlice = [];
// 内容中匹配到的关键词
var contentHitSlice = [];
keywords.forEach(function (keyword) {
/**
* 获取匹配的关键词的索引
* @param {String} keyword 要匹配的关键字
* @param {String} text 原文字
* @param {Boolean} caseSensitive 是否区分大小写
* @param {Number} weight 匹配对象的权重。权重大的优先显示
* @return {Array}
*/
function getIndexByword (word, text, caseSensitive, weight) {
if (!word || !text) {
return [];
};
var startIndex = 0; // 每次匹配的开始索引
var index = -1; // 匹配到的索引值
var result = []; // 匹配结果
if (!caseSensitive) {
word = word.toLowerCase();
text = text.toLowerCase();
}
while((index = text.indexOf(word, startIndex)) !== -1) {
var hasMatch = false;
// 索引位置相同的关键词,保留长度较长的
titleHitSlice.forEach(function (hit) {
if (hit.index === index && hit.word.length < word.length) {
hit.word = word;
hasMatch = true;
}
});
startIndex = index + word.length;
!hasMatch && result.push({ index: index, word: word, weight: weight });
}
return result;
}
titleHitSlice = titleHitSlice.concat(getIndexByword(keyword, titleLower, false, WEIGHT.title));
contentHitSlice = contentHitSlice.concat(getIndexByword(keyword, contentLower, false, WEIGHT.content));
});
var hitTitle = titleHitSlice.length;
var hitContent = contentHitSlice.length;
if (hitTitle > 0 || hitContent > 0) {
isMatch = true;
}
if (isMatch) {
;[titleHitSlice, contentHitSlice].forEach(function (hit) {
// 按照匹配文字的索引的递增顺序排序
hit.sort(function (left, right) {
return left.index - right.index;
});
});
/**
* 给文本中匹配到的关键词添加标记,从而进行高亮显示
* @param {String} text 原文本
* @param {Array} hitSlice 匹配项的索引信息
* @param {Number} start 开始索引
* @param {Number} end 结束索引
* @return {String}
*/
function highlightKeyword (text, hitSlice, start, end) {
if (!text || !hitSlice || !hitSlice.length) {
return;
}
var result = '';
var startIndex = start;
var endIndex = end;
hitSlice.forEach(function (hit) {
if (hit.index < startIndex) {
return;
}
var hitWordEnd = hit.index + hit.word.length;
result += text.slice(startIndex, hit.index);
result += '<b>' + text.slice(hit.index, hitWordEnd) + '</b>';
startIndex = hitWordEnd;
});
result += text.slice(startIndex, endIndex);
return result;
}
var postData = {};
// 文章总的搜索权重
var postWeight = titleHitSlice.length * WEIGHT.title + contentHitSlice.length * WEIGHT.content;
// 标记匹配关键词后的标题
var postTitle = highlightKeyword(title, titleHitSlice, 0, title.length) || title;
// 标记匹配关键词后的内容
var postContent;
// 显示内容的长度
var SHOW_WORD_LENGTH = 200;
// 命中关键词前的字符显示长度
var SHOW_WORD_FRONT_LENGTH = 20;
var SHOW_WORD_END_LENGTH = SHOW_WORD_LENGTH - SHOW_WORD_FRONT_LENGTH;
// 截取匹配的第一个字符,前后共 200 个字符来显示
if (contentHitSlice.length > 0) {
var firstIndex = contentHitSlice[0].index;
var start = firstIndex > SHOW_WORD_FRONT_LENGTH ? firstIndex - SHOW_WORD_FRONT_LENGTH : 0;
var end = firstIndex + SHOW_WORD_END_LENGTH;
postContent = highlightKeyword(content, contentHitSlice, start, end);
} else { // 未匹配到内容,直接截取前 200 个字符来显示
postContent = content.slice(0, SHOW_WORD_LENGTH);
}
postData.title = postTitle;
postData.content = postContent;
postData.url = postURL;
postData.weight = postWeight;
matchPosts.push(postData);
}
});
}
var resultInnerHtml = '';
if (matchPosts.length) {
// 按权重递增的顺序排序,使权重大的优先显示
matchPosts.sort(function (left, right) {
return right.weight - left.weight;
});
resultInnerHtml += '<ul>';
matchPosts.forEach(function (post) {
resultInnerHtml += '<li><a class="search-results-title" href="' + post.url + '">';
resultInnerHtml += post.title;
resultInnerHtml += '</a><div class="search-results-content">';
resultInnerHtml += post.content;
resultInnerHtml += '</div></li>';
});
resultInnerHtml += '</ul>';
} else {
resultInnerHtml += '<div class="search-results-none"><i class="far fa-meh"></i></div>';
}
$result.html(resultInnerHtml);
};
$input.on('input', searchPost);
$input.on('keypress', function (e) {
if (e.keyCode === Stun.utils.codeToKeyCode('Enter')) {
searchPost();
}
});
}
});
}
function closeSearch () {
$('body').css('overflow', 'auto');
$('.search-popup')
.removeClass('show')
.velocity('stop')
.velocity('transition.expandOut', {
duration: 300
});
$('.search-mask')
.velocity('stop')
.velocity('transition.fadeOut', {
duration: 300
});
}
window.addEventListener('DOMContentLoaded', function () {
Stun.utils.pjaxReloadLocalSearch = function () {
$('.header-nav-search').on('click', function (e) {
e.stopPropagation();
$('body').css('overflow', 'hidden');
$('.search-popup')
.addClass('show')
.velocity('stop')
.velocity('transition.expandIn', {
duration: 300,
complete: function () {
$('.search-popup input').focus();
}
});
$('.search-mask')
.velocity('stop')
.velocity('transition.fadeIn', {
duration: 300
});
initSearch();
});
$('.search-mask, .search-close').on('click', function () {
closeSearch();
});
$(document).on('keydown', function (e) {
// Escape <=> 27
if (e.keyCode === Stun.utils.codeToKeyCode('Escape')) {
closeSearch();
}
});
};
Stun.utils.pjaxReloadLocalSearch();
}, false);</script><link href="https://cdn.staticfile.org/KaTeX/0.10.2/katex.min.css" rel="stylesheet" type="text/css"><link href="https://cdn.staticfile.org/KaTeX/0.10.2/contrib/copy-tex.css" rel="stylesheet" type="text/css"><script src="https://cdn.staticfile.org/KaTeX/0.10.2/contrib/copy-tex.min.js"></script><script src="https://cdn.jsdelivr.net/gh/sukkaw/busuanzi@latest/bsz.pure.mini.js" async></script><script src="https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js"></script><script>function loadWaline () {
var GUEST_INFO = ['nick', 'mail', 'link'];
var guest_info = 'nick,mail,link';
guest_info = guest_info.split(',').filter(function(item) {
return GUEST_INFO.indexOf(item) > -1;
});
new Waline({
el: '#waline-container',
serverURL: 'https://comment.cjh0613.com',
placeholder: '点这里输入评论。如果您需要咨询,还可TG联系。(请填写上方昵称与邮箱,邮箱不会公开显示。如果您有个人网站,也可以填写)',
pageSize: '10' || 10,
lang: '' || 'zh-cn',
visitor: false,
avatar: 'mp',
path: window.location.pathname,
meta: guest_info,
avatarCDN: 'https://dn-qiniu-avatar.qbox.me/avatar/',
langMode: { admin: '站长' }
//- avatarCDN: 'https://sdn.geekzu.org/avatar/'
});
}
if (false) {
loadWaline();
} else {
window.addEventListener('DOMContentLoaded', loadWaline, false);
}</script><script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async></script><script>(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: 'ca-pub-3992225808017393',
enable_page_level_ads: true
});</script><script src="https://cjh0613.com/js/counttime.js"></script><script src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/js/utils.js?v=1.7.0"></script><script src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/js/stun-boot.js?v=1.7.0"></script><script src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/js/scroll.js?v=1.7.0"></script><script src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/js/header.js?v=1.7.0"></script><script src="https://cdn.jsdelivr.net/gh/cjh0613/blog@master/js/sidebar.js?v=1.7.0"></script></body></html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/cjh0613/blog.git
[email protected]:cjh0613/blog.git
cjh0613
blog
blog
master

搜索帮助