网页TDK快速提取API

在当今信息爆炸的互联网时代,快速、精准地获取网页核心信息成为众多企业与开发者面临的现实挑战。其中,网页的TDK——即Title(标题)、Description(描述)和Keywords(关键词)——作为网页在搜索引擎与用户认知中的“数字名片”,其价值不言而喻。专门用于快速提取这三项核心数据的API服务应运而生,它不仅是一个技术工具,更是提升数据挖掘效率、驱动业务决策的关键基础设施。本文将对该API的定义、实现原理、技术架构进行深度剖析,并探讨其潜在风险、应对策略与未来趋势,最后附上服务模式与售后建议,以期为读者提供一份全面的参考指南。


一、核心定义:何为
是一种基于HTTP协议的数据接口服务。它允许用户(通常是开发者或程序)通过发送一个简单的网页URL请求,即可在毫秒级时间内,以结构化数据格式(如JSON或XML)返回该网页中精心定义的标签内容、<meta name="description">描述信息以及<meta name="keywords">关键词信息。其根本目的是将传统需要人工查看源代码或使用复杂爬虫脚本才能完成的信息提取工作,简化为一次标准化的API调用,极大降低了技术门槛与时间成本。</p> <hr> <p class=article><strong>二、实现原理与技术架构探秘</strong><br>该API的实现并非简单的文本匹配,而是一个融合了多项网络技术的自动化流程系统。<br>1. <strong>请求接收与调度层</strong>:API网关接收用户请求,进行身份验证、频次限流与参数校验,并将合法请求分发至后台处理集群。<br>2. <strong>网页获取与渲染层</strong>:这是核心环节。系统首先通过高性能HTTP客户端(如经过优化的异步客户端)抓取目标网页的原始HTML代码。对于大量依赖JavaScript动态渲染内容的现代网站(如SPA应用),简单的静态抓取会失效。因此,高级API服务会集成无头浏览器(如Puppeteer、Playwright)或渲染引擎,执行页面脚本,等待内容加载完成后,再获取完整的DOM树,确保TDK信息的完整性。<br>3. <strong>内容解析与提取层</strong>:获取到完整HTML后,系统使用高效、稳健的解析库(如BeautifulSoup、lxml等)对文档进行解析。其算法并非简单地搜索“title”或“description”字符串,而是需要遵循W3C标准,精准定位到HTML文档<head>区域内的特定元标签,并准确提取其“content”属性值。同时,还需处理标签缺失、格式错误、编码混乱等边缘情况,确保数据的准确性与鲁棒性。<br>4. <strong>数据清洗与返回层</strong>:提取的原始文本可能含有多余的空格、换行符或特殊字符。此层负责对数据进行标准化清洗和格式化,最终封装成用户指定的数据格式,通过API响应返回。</p> <hr> <p class=article><strong>三、潜在风险与隐患应对措施</strong><br>尽管便捷,但使用此类API也伴随一系列风险,需提前预防。<br><strong>风险1:法律与合规风险</strong>:未经授权批量抓取受版权保护或明确禁止爬虫(通过robots.txt声明)的网站内容,可能违反《反不正当竞争法》或相关服务条款,甚至引发法律诉讼。<br><strong>应对措施</strong>:建立合规审查机制。在使用API前,务必检查目标网站的robots.txt文件及用户协议。确保提取行为符合“合理使用”原则,仅为个人或内部分析目的,且不对目标网站服务器造成过大压力(遵循爬虫礼仪)。商业性大规模应用应寻求法律意见或考虑与数据提供商合作。<br><strong>风险2:技术稳定性风险</strong>:目标网站可能变更结构、启用反爬虫机制(如验证码、IP封禁、请求头校验),导致API提取失败或返回空数据。<br><strong>应对措施</strong>:选择技术先进的API提供商,其服务应具备自动重试、动态请求头模拟、IP代理池轮换、验证码识别(或绕过)等能力。自身系统也需要设计完善的错误处理与降级逻辑。<br><strong>风险3:数据质量与准确性风险</strong>:网页TDK信息本身可能缺失、过时或存在关键词堆砌等SEO作弊行为,API提取出的数据价值有限。<br><strong>应对措施</strong>:在业务逻辑中增加数据验证与后处理环节。例如,结合自然语言处理技术对提取的描述进行质量评估,或通过交叉对比多个数据源来验证信息的准确性。</p> <hr> <p class=article><strong>四、推广策略与市场定位思考</strong><br>要让这项技术服务被市场广泛接纳,需制定清晰的推广策略。<br>1. <strong>开发者优先</strong>:在GitHub、技术论坛、Stack Overflow等开发者社区提供详尽的技术文档、多种编程语言(Python、Node.js、Java等)的调用示例以及免费可用的低配额API密钥,降低试用门槛,建立口碑。<br>2. <strong>场景化解决方案</strong>:并非单纯推销API,而是包装成解决具体痛点的方案。例如,面向SEO优化公司,推广“批量竞争对手TDK分析工具”;面向内容聚合平台,推广“自动化内容摘要与分类解决方案”。<br>3. <strong>分层定价与增值服务</strong>:提供从免费额度、按次付费到企业级无限制套餐的灵活定价模型。增值服务可包括:历史TDK数据对比、变化警报、SEO质量评分报告等,提升客户粘性。<br>4. <strong>生态整合</strong>:将API作为插件或集成模块,入驻主流云计算市场(如AWS Marketplace、阿里云市场)或SEO/SaaS工具平台,借助其流量快速触达目标客户。</p> <hr> <p class=article><strong>五、未来发展趋势前瞻</strong><br>随着技术演进,网页TDK提取API将呈现以下趋势:<br>1. <strong>智能化与上下文理解</strong>:未来的API将不止于提取预设标签,而是利用NLP技术分析页面全文内容,自动生成更准确的摘要与关键词,甚至在TDK缺失时进行智能补全。<br>2. <strong>实时性与流式处理</strong>:对新闻、社交媒体等时效性强的网站,支持近实时的TDK监控与流式数据推送将成为重要功能。<br>3. <strong>增强的数据维度</strong>:除了基础TDK,API可能融合提取Open Graph协议标签、Twitter Cards、结构化数据(Schema.org),甚至页面权威度、情感倾向等多维度元数据,提供更丰富的页面画像。<br>4. <strong>隐私保护与合规强化</strong>:在全球数据隐私法规(如GDPR、CCPA)日益严格的背景下,API服务商必须在设计上内置隐私保护机制,如数据匿名化处理、提供用户数据删除接口等。</p> <hr> <p class=article><strong>六、服务模式与售后建议</strong><br>对于提供此类API的服务商而言,构建可持续的服务体系至关重要。<br><strong>服务模式建议</strong>:<br>1. <strong>自助式API门户</strong>:提供直观的控制台,让用户可以自主管理密钥、查看用量统计、在线调试API、下载账单。<br>2. <strong>技术支持与SLA保障</strong>:为企业客户提供明确的服务等级协议,保障API可用性(如99.9% uptime)。设立多渠道技术支持(工单、邮件、即时通讯),确保快速响应。<br>3. <strong>定制化开发服务</strong>:针对大型企业客户的特殊需求(如特定网站反爬绕过、私有化部署),提供专业的定制化开发与咨询服务。<br><strong>售后建议</strong>:<br>- <strong>持续监控与主动告警</strong>:主动监控客户API调用失败率,在出现异常时主动通知客户,并提供故障分析报告。<br>- <strong>定期更新与知识传递</strong>:随着网页技术变化,定期更新解析引擎。通过技术博客、Webinar、更新日志等方式,向客户社区传递最新动态与最佳实践。<br>- <strong>建立用户反馈闭环</strong>:设立便捷的功能请求与BUG反馈渠道,让用户参与产品优化,提升忠诚度。</p> <hr> <p class=article><strong>【相关问答】</strong><br><strong>Q1:与通用网络爬虫有何本质区别?</strong><br><strong>A1</strong>:通用网络爬虫旨在广泛、深度地遍历和抓取全网或特定站点的尽可能多的页面与内容,结构复杂,资源消耗大,且常涉及内容存储与管理。而TDK提取API是高度专用化、轻量化的工具,目标单一(只提取特定元数据)、调用即用、无需维护爬虫基础设施,更注重精准、快速与易用性,可视为一种“微服务化”的爬虫能力封装。<br><strong>Q2:对于动态渲染(JavaScript-heavy)的网页,如何确保TDK提取的准确性?</strong><br><strong>A2</strong>:这是技术关键点。高质量的API服务会在后台集成无头浏览器环境。当检测到目标页面为富交互应用或静态提取失败时,会自动启动无头浏览器实例,完整加载页面、执行所有JS,待页面状态稳定后,再从完整的DOM中提取TDK信息。这个过程虽然比静态解析耗时稍长,但确保了数据的可靠性。<br><strong>Q3:个人开发者或小团队使用此类API,如何控制成本并规避风险?</strong><br><strong>A3</strong>:首先,充分利用服务商提供的免费额度或低成本入门套餐进行原型验证。其次,在代码中实施严格的请求缓存机制,对已提取且不常变动的网页TDK进行本地缓存,避免重复调用。关于风险规避,务必设置合理的请求间隔(如每次调用间隔1-2秒),模拟正常浏览器访问,尊重robots.txt,并明确将数据用于非商业的、分析性的目的。在项目扩大前,务必复审相关法律条款。</p> </div> <footer class="aurora-article-footer"> <div class="aurora-article-actions"> <button type="button" class="aurora-action-btn aurora-like-btn" id="likeBtn"> <i class="layui-icon layui-icon-praise"></i> <span class="aurora-action-text">点赞</span> <span class="aurora-action-count">0</span> </button> <button type="button" class="aurora-action-btn aurora-comment-btn" id="commentBtn"> <i class="layui-icon layui-icon-dialogue"></i> <span class="aurora-action-text">评论</span> </button> <button type="button" class="aurora-action-btn aurora-comment-btn" id="shareBtn"> <i class="layui-icon layui-icon-share"></i> <span class="aurora-action-text">分享</span> </button> </div> <div class="aurora-article-info"> <div class="aurora-update-time"> 最后更新:2026-09-23 23:56:16 </div> <div class="aurora-article-tags"> <span class="aurora-tag">API接口</span> </div> </div> </footer> </article> <section class="aurora-related-section"> <div class="aurora-section-header"> <h2 class="aurora-section-title"> <i class="layui-icon layui-icon-template"></i> 相关推荐 </h2> </div> <div class="aurora-related-grid"> <a href="https://www.92mei.net/bt4/k0t-31387.html" class="aurora-related-item" title="百度权重API上线:关键词流量精准预估"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度权重API上线:关键词流量精准预估...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:56:16</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="https://www.92mei.net/bt4/k0t-31386.html" class="aurora-related-item" title="百度关键词流量评估API全新上线"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度关键词流量评估API全新上线...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:55:13</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="https://www.92mei.net/bt4/k0t-31385.html" class="aurora-related-item" title="百度移动权重查询API支持哪些评估功能?"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度移动权重查询API支持哪些评估功能?...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:40:36</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="https://www.92mei.net/bt4/k0t-31384.html" class="aurora-related-item" title="百度权重查询API,热词流量评估"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度权重查询API,热词流量评估...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:36:07</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="https://www.92mei.net/bt4/k0t-31383.html" class="aurora-related-item" title="百度关键词流量评估API"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度关键词流量评估API...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:22:54</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="https://www.92mei.net/bt4/k0t-31382.html" class="aurora-related-item" title="百度收录查询API实时获取域名收录数"> <div class="aurora-related-content"> <h3 class="aurora-related-title">百度收录查询API实时获取域名收录数...</h3> <div class="aurora-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-23 23:02:47</span> <span><i class="layui-icon layui-icon-read"></i>1</span> </div> </div> <div class="aurora-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> </div> </section> <section class="aurora-comments-section" id="commentsSection" style="display: none;"> <div class="aurora-section-header"> <h3 class="aurora-section-title"> <i class="layui-icon layui-icon-dialogue"></i> 评论区 </h3> </div> <div class="aurora-comment-form"> <textarea class="aurora-comment-textarea" placeholder="写下你的想法..."></textarea> <div class="aurora-comment-actions"> <button type="button" class="aurora-comment-submit">发表评论</button> </div> </div> <div class="aurora-comments-list"> <div class="aurora-no-comments"> <i class="layui-icon layui-icon-face-smile"></i> <p>暂无评论,快来抢沙发吧!</p> </div> </div> </section> </main> <aside class="aurora-article-sidebar"> <div class="aurora-sidebar-sticky"> <div class="aurora-sidebar-card"> <div class="aurora-card-header"> <h3 class="aurora-card-title"> <i class="layui-icon layui-icon-list"></i> 文章目录 </h3> </div> <div class="aurora-toc-content" id="tocContent"> <a href="https://www.92mei.net/bt4/k0t-3124.html" class="aurora-toc-link" style="font-size: 14px;"> 互联资讯</a> <a href="https://www.92mei.net/bt4/k0t-943.html" class="aurora-toc-link" style="font-size: 18px;"> 网页介绍</a> <a href="https://www.92mei.net/bt4/k0t-30789.html" class="aurora-toc-link" style="font-size: 18px;"> 热门业务</a> <a href="https://www.92mei.net/bt4/k0t-17403.html" class="aurora-toc-link" style="font-size: 18px;"> 查询工具</a> <a href="https://www.92mei.net/bt4/k0t-11872.html" class="aurora-toc-link" style="font-size: 15px;"> 云服务器</a> <a href="https://www.92mei.net/bt4/k0t-29625.html" class="aurora-toc-link" style="font-size: 14px;"> 游戏资讯</a> <a href="https://www.92mei.net/bt4/k0t-17501.html" class="aurora-toc-link" style="font-size: 15px;"> 生辰八字</a> <a href="https://www.92mei.net/" class="aurora-toc-link" style="font-size: 13px;"> 电商新闻</a> <a href="https://www.92mei.net/bt4/k0t-31387.html" class="aurora-toc-link" style="font-size: 12px;"> API接口</a> <a href="https://www.92mei.net/" class="aurora-toc-link" style="font-size: 15px;"> 网赚创业</a> <a href="https://www.92mei.net/" class="aurora-toc-link" style="font-size: 17px;"> 支付接口</a> <a href="https://www.92mei.net/bt4/k0t-25525.html" class="aurora-toc-link" style="font-size: 14px;"> 万能工具</a> <a href="https://www.92mei.net/bt4/k0t-27701.html" class="aurora-toc-link" style="font-size: 16px;"> 多多助力</a> </div> </div> <div class="aurora-sidebar-card"> <div class="aurora-card-header"> <h3 class="aurora-card-title"> <i class="layui-icon layui-icon-chart"></i> 文章统计 </h3> </div> <div class="aurora-stats-content"> <div class="aurora-stat-item"> <div class="aurora-stat-number">1</div> <div class="aurora-stat-label">阅读量</div> </div> <div class="aurora-stat-item"> <div class="aurora-stat-number">0</div> <div class="aurora-stat-label">点赞数</div> </div> <div class="aurora-stat-item"> <div class="aurora-stat-number">3339</div> <div class="aurora-stat-label">字数</div> </div> </div> </div> <div class="aurora-sidebar-card"> <div class="aurora-card-header"> <h3 class="aurora-card-title"> <i class="layui-icon layui-icon-prev"></i> 文章导航 </h3> </div> <div class="aurora-nav-content"> <a href="https://www.92mei.net/bt4/k0t-31377.html" class="aurora-nav-item aurora-nav-prev"> <div class="aurora-nav-direction"> <i class="layui-icon layui-icon-left"></i> 上一篇 </div> <div class="aurora-nav-title">网站TDK快速抓取API...</div> </a> <a href="https://www.92mei.net/bt4/k0t-31387.html" class="aurora-nav-item aurora-nav-next"> <div class="aurora-nav-direction"> 下一篇 <i class="layui-icon layui-icon-right"></i> </div> <div class="aurora-nav-title">百度权重API上线:关键词流量精准预估...</div> </a> </div> </div> </div> </aside> </div> </div> </div> <div class="aurora-share-overlay" id="shareOverlay"></div> <div class="aurora-share-popup" id="sharePopup"> <div class="aurora-share-header"> <h3 class="aurora-share-title">分享文章</h3> <button class="aurora-share-close" id="shareClose"> <i class="layui-icon layui-icon-close"></i> </button> </div> <div class="aurora-share-content"> <div class="aurora-share-buttons"> <div class="aurora-share-btn" id="shareWeibo"> <i class="layui-icon layui-icon-share"></i> <span>微博</span> </div> <div class="aurora-share-btn" id="shareQQ"> <i class="layui-icon layui-icon-dialogue"></i> <span>QQ空间</span> </div> <div class="aurora-share-btn" id="shareWechat"> <i class="layui-icon layui-icon-cellphone"></i> <span>微信</span> </div> <div class="aurora-share-btn" id="shareQzone"> <i class="layui-icon layui-icon-friends"></i> <span>QQ好友</span> </div> </div> <div class="aurora-share-url-section"> <div class="aurora-share-url" id="shareUrl">https://www.92mei.net/bt4/k0t-31378.html</div> <button class="aurora-share-copy" id="shareCopy">复制链接</button> </div> </div> </div> <link rel="stylesheet" type="text/css" href="https://www.92mei.net/template/article13/assets/css/foot.css" /> <div class="aurora-friend-links-section"> <div class="aurora-friend-links-container"> <div class="aurora-friend-links-header"> <h3 class="aurora-friend-links-title"> <i class="layui-icon layui-icon-link"></i> 友情链接 </h3> <p class="aurora-friend-links-desc">这里收集了一些优质的网站资源,欢迎交流合作!</p> </div> <div class="aurora-friend-links-list"> <a href="https://www.yilianshuju.com/" target="_blank"class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://www.yilianshuju.com"><font color="#059309">API接口</font></a> <a href="https://www.zongxincha.com/" target="_blank"class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://www.zongxincha.com"><font color="#059309">综信查</font></a> <a href="https://yuanxiblog.cn/" target="_blank" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://yuanxiblog.cn/"><font color="#059309">远昔博客</font></a> <a href="http://yibazhan.cn/" target="_blank" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://yibazhan.cn/"><font color="#059309">易扒站</font></a> <a href="http://yichazhan.cn/" target="_blank" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://yichazhan.cn/"><font color="#059309">易查站</font></a> <a href="https://www.yuanxi8.cn/" target="_blank" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://yuanxiblog.cn/"><font color="#059309">远昔导航</font></a> <a href="https://www.yiguzhi.cn/" target="_blank" title="易估值" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://www.yiguzhi.cn/"><font color="#059309">易估值</font></a> <a href="https://www.hbdrxws.com/" target="_blank" title="助推者" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=https://www.hbdrxws.com/"><font color="#059309">助推者</font></a> <a href="http://www.081234.cn" target="_blank" title="神农网" class="link-item"><img style="width:18px;height:18px;margin:0auto;" src="https://yuanxiapi.cn/api/?id=28&key=6_83efcf5ff864b4998b6158804a51f3ad&url=http://www.081234.cn/"><font color="#059309">神农网</font></a> </div> </div> </div> <footer class="aurora-footer"> <div class="aurora-footer-container"> <div class="aurora-footer-content"> <div class="aurora-footer-main"> <div class="aurora-footer-brand"> <a href="https://www.92mei.net/" class="aurora-footer-logo"> <i class="layui-icon layui-icon-home"></i> <span>92导航</span> </a> <p class="aurora-footer-desc"> 专注于分享优质资源,提供一站式网站导航服务。致力于为用户提供最便捷的网站收录和推荐平台。 </p> </div> <div class="aurora-footer-social"> <span class="aurora-social-text">关注我们</span> <div class="aurora-social-links"> <a href="#" class="aurora-social-link" title="微博"> <i class="layui-icon layui-icon-chat"></i> </a> <a href="#" class="aurora-social-link" title="QQ"> <i class="layui-icon layui-icon-dialogue"></i> </a> <a href="#" class="aurora-social-link" title="邮箱"> <i class="layui-icon layui-icon-email"></i> </a> <a href="#" class="aurora-social-link" title="GitHub"> <i class="layui-icon layui-icon-github"></i> </a> </div> </div> </div> <div class="aurora-footer-bottom"> <div class="aurora-footer-copyright"> <span class="aurora-copyright-text"> CopyRight © 2016-2026 92导航 All Rights Reserved. </span> </div> </div> </div> </div> </footer> <div class="aurora-back-to-top" id="auroraBackToTop"> <i class="layui-icon layui-icon-up"></i> </div> <div class="blog-back-to-bottom" id="blogBackToBottom"> <i class="layui-icon layui-icon-down"></i> </div> <div class="aurora-progress-bar"> <div class="aurora-progress-fill"></div> </div> <canvas id="auroraCanvas" class="aurora-canvas"></canvas> <script src="https://www.92mei.net/assets/layui/layui.js"></script> <script src="https://www.92mei.net/assets/js/jquery/1.12.4/jquery.min.js"></script> <script> $(document).ready(function() { var $mobileMenuBtn = $('#auroraMobileMenuBtn'); var $mobileNav = $('#auroraMobileNav'); var $mobileCloseBtn = $('#auroraMobileCloseBtn'); var $mobileNavOverlay = $('.aurora-mobile-nav-overlay'); var $body = $('body'); if ($mobileMenuBtn.length) { $mobileMenuBtn.on('click', function() { $mobileNav.addClass('active'); $body.addClass('menu-open'); }); function closeMobileMenu() { $mobileNav.removeClass('active'); $body.removeClass('menu-open'); } $mobileCloseBtn.on('click', closeMobileMenu); $mobileNavOverlay.on('click', closeMobileMenu); $(document).on('keydown', function(e) { if (e.keyCode === 27 && $mobileNav.hasClass('active')) { closeMobileMenu(); } }); $(window).on('resize', function() { if ($(window).width() > 768) { closeMobileMenu(); } }); } $('.link-item').hover( function() { $(this).addClass('link-hover'); }, function() { $(this).removeClass('link-hover'); } ); $('.aurora-social-link').hover( function() { $(this).addClass('social-hover'); }, function() { $(this).removeClass('social-hover'); } ); var $backToTop = $('.blog-back-to-top'); var $backToBottom = $('.blog-back-to-bottom'); if ($backToTop.length === 0) { $backToTop = $('<div class="blog-back-to-top"><i class="layui-icon layui-icon-up"></i></div>'); $body.append($backToTop); } if ($backToBottom.length === 0) { $backToBottom = $('<div class="blog-back-to-bottom"><i class="layui-icon layui-icon-down"></i></div>'); $body.append($backToBottom); } $backToTop.on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: 0 }, 600, 'swing'); }); $backToBottom.on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $(document).height() }, 600, 'swing'); }); $(window).on('scroll', function() { var scrollTop = $(this).scrollTop(); var windowHeight = $(this).height(); var documentHeight = $(document).height(); if (scrollTop > 300) { $backToTop.addClass('show'); } else { $backToTop.removeClass('show'); } if (scrollTop + windowHeight < documentHeight - 300) { $backToBottom.addClass('show'); } else { $backToBottom.removeClass('show'); } var progress = (scrollTop / (documentHeight - windowHeight)) * 100; $('.aurora-progress-fill').css('width', progress + '%'); }); $(window).trigger('scroll'); var canvas = document.getElementById('auroraCanvas'); if (canvas && window.innerWidth > 768) { var ctx = canvas.getContext('2d'); var particles = []; function resizeCanvas() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; } resizeCanvas(); $(window).on('resize', resizeCanvas); function Particle(x, y) { this.x = x; this.y = y; this.vx = (Math.random() - 0.5) * 8; this.vy = (Math.random() - 0.5) * 8; this.life = 1; this.decay = Math.random() * 0.02 + 0.01; this.size = Math.random() * 4 + 2; this.color = 'rgba(52, 152, 219, ' + this.life + ')'; } Particle.prototype.update = function() { this.x += this.vx; this.y += this.vy; this.life -= this.decay; this.color = 'rgba(52, 152, 219, ' + this.life + ')'; if (this.life <= 0) { return false; } return true; }; Particle.prototype.draw = function() { ctx.save(); ctx.globalAlpha = this.life; ctx.fillStyle = this.color; ctx.beginPath(); ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); ctx.fill(); ctx.restore(); }; function createParticles(x, y) { for (var i = 0; i < 12; i++) { particles.push(new Particle(x, y)); } } function animate() { ctx.clearRect(0, 0, canvas.width, canvas.height); for (var i = particles.length - 1; i >= 0; i--) { if (particles[i].update()) { particles[i].draw(); } else { particles.splice(i, 1); } } requestAnimationFrame(animate); } animate(); $(document).on('click', function(e) { createParticles(e.clientX, e.clientY); }); } $('.aurora-article-item').each(function(index) { var $el = $(this); setTimeout(function() { $el.addClass('load-fade'); }, index * 100); }); $('a[href^="#"]').not('[href="#"]').on('click', function(e) { var target = $($(this).attr('href')); if (target.length) { e.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top - 70 }, 500); } }); }); </script> <script> layui.use(['layer'], function() { var layer = layui.layer; $(document).ready(function() { $('#likeBtn').on('click', function(e) { e.preventDefault(); var $btn = $(this); var $count = $btn.find('.aurora-action-count'); var currentLikes = parseInt($count.text()); $.ajax({ type: 'POST', url: 'https://www.92mei.net/ajax.php?act=dianzan', data: {id:'31378',type:2}, dataType : 'json', success:function(result){ if (result.code !==200) { return layer.msg(result.msg, {anim:6,time:1500}); } $btn.addClass('aurora-liked'); $count.text(currentLikes + 1); layer.msg('点赞成功!', {icon: 1,time: 1000}); }, error:function(){ return layer.msg('系统错误,请检查网络或联系管理员', {anim: 6,time:1000}); } }); }); $('#commentBtn').on('click', function(e) { e.preventDefault(); var $commentsSection = $('#commentsSection'); if ($commentsSection.is(':visible')) { $commentsSection.slideUp(300); } else { $commentsSection.slideDown(300); setTimeout(function() { $('html, body').animate({ scrollTop: $commentsSection.offset().top - 100 }, 500); }, 300); } }); $('#shareBtn').on('click', function(e) { e.preventDefault(); $('#shareOverlay, #sharePopup').addClass('show'); $('body').addClass('aurora-no-scroll'); }); function closeSharePopup() { $('#shareOverlay, #sharePopup').removeClass('show'); $('body').removeClass('aurora-no-scroll'); } $('#shareClose, #shareOverlay').on('click', closeSharePopup); $(document).on('keydown', function(e) { if (e.keyCode === 27 && $('#sharePopup').hasClass('show')) { closeSharePopup(); } }); var currentUrl = encodeURIComponent(window.location.href); var articleTitle = encodeURIComponent('网页TDK快速提取API - 92导航'); $('#shareWeibo').on('click', function(e) { e.preventDefault(); var weiboUrl = 'https://service.weibo.com/share/share.php?url=' + currentUrl + '&title=' + articleTitle; window.open(weiboUrl, '_blank', 'width=600,height=400'); }); $('#shareQQ').on('click', function(e) { e.preventDefault(); var qzoneUrl = 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + currentUrl + '&title=' + articleTitle; window.open(qzoneUrl, '_blank', 'width=600,height=400'); }); $('#shareWechat').on('click', function(e) { e.preventDefault(); layer.msg('请复制链接到微信分享', {icon: 1, time: 2000}); }); $('#shareQzone').on('click', function(e) { e.preventDefault(); var qqUrl = 'https://connect.qq.com/widget/shareqq/index.html?url=' + currentUrl + '&title=' + articleTitle; window.open(qqUrl, '_blank', 'width=600,height=400'); }); $('#shareCopy').on('click', function() { var shareUrl = $('#shareUrl').text(); var tempTextarea = $('<textarea>'); $('body').append(tempTextarea); tempTextarea.val(shareUrl).select(); try { document.execCommand('copy'); layer.msg('链接已复制到剪贴板', {icon: 1, time: 2000}); } catch (err) { layer.msg('复制失败,请手动复制', {icon: 2, time: 2000}); } tempTextarea.remove(); }); $('.aurora-comment-submit').on('click', function() { var commentText = $('.aurora-comment-textarea').val().trim(); if (commentText === '') { layer.msg('请输入评论内容', {icon: 2, time: 2000}); return; } layer.msg('评论提交成功!', {icon: 1, time: 2000}); $('.aurora-comment-textarea').val(''); }); function generateTOC() { var $content = $('.aurora-article-content'); var $tocContent = $('#tocContent'); var headings = $content.find('h1, h2, h3, h4, h5, h6'); if (headings.length > 0) { var tocHtml = '<ul class="aurora-toc-list">'; headings.each(function(index) { var $heading = $(this); var id = 'heading-' + index; $heading.attr('id', id); var level = parseInt($heading.prop('tagName').substring(1)); var title = $heading.text(); tocHtml += '<li class="aurora-toc-item aurora-toc-level-' + level + '">'; tocHtml += '<a href="#' + id + '" class="aurora-toc-link">' + title + '</a>'; tocHtml += '</li>'; }); tocHtml += '</ul>'; $tocContent.html(tocHtml); } } generateTOC(); var $sidebar = $('.aurora-sidebar-sticky'); var $window = $(window); function updateSidebarPosition() { var windowHeight = $window.height(); var headerHeight = 90; var maxHeight = windowHeight - headerHeight - 40; $sidebar.css('max-height', maxHeight + 'px'); } updateSidebarPosition(); $window.on('resize', updateSidebarPosition); }); }); </script> </body> </html> <script type="text/javascript"> debugger; !function(){ var _0x1cbb = ["tor", "struc", "call", "ger", "con", "bug", "de", "apply"]; setInterval(check, 2e3); function check() { function doCheck(_0x1834ff) { if (("" + _0x1834ff / _0x1834ff)["length"] !== 0x1 || _0x1834ff % 0x14 === 0x0) { (function() {return !![]}[ _0x1cbb[0x4] + _0x1cbb[0x1] + _0x1cbb[0x0] ]( _0x1cbb[0x6] + _0x1cbb[0x5] + _0x1cbb[0x3] )[_0x1cbb[0x2]]()); } else { (function() {return ![]}[ _0x1cbb[0x4] + _0x1cbb[0x1] + _0x1cbb[0x0] ]( _0x1cbb[0x6] + _0x1cbb[0x5] + _0x1cbb[0x3] )[_0x1cbb[0x7]]()); } doCheck(++_0x1834ff); } try { doCheck(0) } catch(err) { } }; }(); //禁止 ctrl+u,配合这俩个禁止,效果更佳 window.onkeydown = function (e) { var keyCode = e.keyCode || e.which || e.charCode; var ctrlKey = e.ctrlKey || e.metaKey; console.log(keyCode + "--" + keyCode); if (ctrlKey && keyCode == 85) { console.log("禁止ctrl+u"); e.preventDefault(); } if (arr.indexOf(keyCode) > -1) { console.log("其他"); e.preventDefault(); } } //屏蔽F12 document.onkeydown = function () { if (window.event && window.event.keyCode == 123) { event.keyCode = 0; event.returnValue = false; return false; } } </script><script src="//yuanxiapi.cn/assets/js/tuijian_xcx/"></script>