SEO优化利器:TDK抓取API的精准应用案例

在当今数字化营销的浪潮中,SEO(搜索引擎优化)始终是企业与个人获取线上流量的核心。而在众多优化工具中,TDK(Title, Description, Keywords)抓取API作为一种精准的数据获取手段,正逐渐成为SEO专业人士的“利器”。本文将摒弃泛泛而谈,直接切入用户最关心的核心,以FAQ问答形式,深入剖析TDK抓取API的十大高频应用问题,并提供每一步都可落地的解决方案与实操步骤,旨在显著提升您网站的搜索友好度与内容竞争力。


问题一:TDK抓取API究竟是什么?它与普通网页爬虫有何本质区别?

许多用户初次接触时,常将TDK抓取API与普通网络爬虫混为一谈。事实上,两者在目标与精度上存在显著差异。TDK抓取API是一种专门设计用于从目标网页源代码的特定元标签(即Title标题、Description描述、Keywords关键词)中,高效、结构化地提取核心SEO数据的编程接口。相较于普通爬虫可能无差别地抓取整个页面内容(包括大量无关文本、图片链接等),TDK API的抓取行为更为聚焦,直接锁定、<meta name="description"和<meta name="keywords"这些关键字段,数据输出干净、即时,极大减少了后续数据清洗的工作量,为竞品分析、内容优化提供“弹药”。</p> <hr> <p class=article><strong>问题二:在哪些具体场景下,我必须使用TDK抓取API而非手动查看?</strong></p> <p class=article>手动查看源代码适用于极少量页面的临时检查。但在以下场景,API的优势无可替代:1. <strong>大规模竞品监控</strong>:需定期跟踪数十上百个竞争对手网站的核心页面TDK策略变化。2. <strong>网站SEO审计</strong>:对自己拥有海量页面的网站进行TDK完整性、规范性普查。3. <strong>内容策略制定</strong>:通过批量分析某个关键词下排名靠前页面的TDK撰写规律,指导自身内容创作。4. <strong>外链建设评估</strong>:在寻找外链机会时,快速评估目标网站的页面主题相关性。手动操作在这些场景下耗时耗力且极易出错,而API可实现自动化、批量化处理。</p> <hr> <p class=article><strong>问题三:如何选择或获取一个可靠且高效的TDK抓取API服务?</strong></p> <p class=article>选择API服务时,应重点关注以下几点:1. <strong>稳定性与成功率</strong>:选择能处理各种网站结构、抗反爬能力强、保证高抓取成功率的服务商。2. <strong>响应速度与延迟</strong>:API的响应时间直接影响批量处理效率,建议优先选择低延迟服务。3. <strong>数据格式与纯净度</strong>:确保返回的数据(通常是JSON格式)已清晰剥离出标题、描述、关键词字段,无需复杂解析。4. <strong>调用频率与成本</strong>:根据自身需求(如每日抓取量)权衡免费额度、套餐价格与调用限制。市面上一些成熟的云端API提供商(如SerpAPI、ScraperAPI的特定端点)或开源的自建解决方案(结合Python的Requests库与BeautifulSoup)均可作为选项,需根据技术能力与预算抉择。</p> <hr> <p class=article><strong>问题四:能否详细展示一个从零开始的完整API调用与数据获取实操步骤?</strong></p> <p class=article>以下以使用Python调用一个假设的TDK API为例:<br> 步骤1:<strong>注册并获取API密钥</strong>:在所选服务商平台完成注册,于控制台获取唯一的API Key。<br> 步骤2:<strong>准备请求环境</strong>:确保已安装Python及requests库(可通过pip install requests安装)。<br> 步骤3:<strong>构建API请求</strong>:假设API端点为 https://api.example.com/tdk,请求方式为GET,参数为url(目标网址)和api_key。<br> 步骤4:<strong>编写并执行代码</strong>: python import requests api_endpoint = "https://api.example.com/tdk" api_key = "YOUR_ACTUAL_API_KEY_HERE" target_url = "https://www.competitor-example.com/product-page" params = { 'url': target_url, 'api_key': api_key } response = requests.get(api_endpoint, params=params) if response.status_code == 200: data = response.json title = data.get('title') description = data.get('description') keywords = data.get('keywords') print(f"标题:{title}\n描述:{description}\n关键词:{keywords}") else: print(f"请求失败,状态码:{response.status_code}") <br> 步骤5:<strong>处理与存储数据</strong>:将获取到的数据存入Excel、CSV或数据库中,以备分析。</p> <hr> <p class=article><strong>问题五:如何处理目标网站设置的反爬虫机制(如IP封锁、验证码)?</strong></p> <p class=article>这是实战中的常见挑战。解决方案需多管齐下:1. <strong>使用代理IP池</strong>:通过轮换多个IP地址(可使用付费代理服务)来分散请求,避免单一IP触发封锁。2. <strong>设置合理的请求间隔</strong>:在代码中(如使用time.sleep)加入随机延迟,模拟人类浏览行为,降低请求频率。3. <strong>完善请求头(Headers)</strong>:在API请求中携带完整的User-Agent、Referer等头部信息,使其更像浏览器发起。4. <strong>选择具备抗反爬能力的API服务</strong>:许多专业API服务已内置了代理轮换、浏览器引擎渲染等高级功能。请注意,始终应遵守目标网站的robots.txt协议,尊重对方服务器的负载能力。</p> <hr> <p class=article><strong>问题六:抓取到的TDK数据,如何转化为具体的SEO优化行动?</strong></p> <p class=article>获取数据仅是第一步,关键在于分析与应用:1. <strong>竞品差距分析</strong>:对比自己与竞品页面在标题关键词前置、描述吸引力、关键词密度与分布上的差异。2. <strong>发现内容空白点</strong>:分析竞品覆盖的关键词集群,找到他们未覆盖但搜索意图明确的关联长尾词,作为自己内容创作的方向。3. <strong>优化自身TDK</strong>:借鉴优秀竞品的结构(如标题长度控制、描述中行动号召语的运用),但务必创作独特、更优质的内容,避免简单复制。4. <strong>监测优化效果</strong>:在实施优化后,定期使用同一API抓取自己页面的TDK(确保已生效),并观察该页面在搜索引擎中的排名变动,形成“分析-优化-监测”的闭环。</p> <hr> <p class=article><strong>问题七:在批量抓取时,如何高效管理和分析成千上万条抓取结果?</strong></p> <p class=article>海量数据管理推荐以下流程:1. <strong>自动化脚本与任务调度</strong>:编写脚本实现URL列表的循环抓取,并利用系统任务(如Linux的Cron)或云函数定时执行。2. <strong>结构化存储</strong>:将结果实时或批量存入关系型数据库(如MySQL)或NoSQL数据库(如MongoDB),便于关联查询。3. <strong>数据分析与可视化</strong>:使用Python的Pandas进行数据清洗和统计分析(如统计高频关键词);利用Tableau或Power BI制作仪表盘,直观展示竞品TDK策略趋势。4. <strong>设置异常警报</strong>:监控抓取失败率、数据字段缺失率等指标,一旦异常立即通知,保证数据源的稳定性。</p> <hr> <p class=article><strong>问题八:使用TDK抓取API是否存在法律与道德风险?如何合规使用?</strong></p> <p class=article>这是一个至关重要的议题。核心原则是“合规与尊重”。1. <strong>遵守《 robots.txt 》协议</strong>:抓取前检查目标网站的robots.txt文件,尊重其中关于禁止抓取(Disallow)的声明。2. <strong>切勿侵犯版权与隐私</strong>:抓取的TDK数据(尤其是标题、描述)可能受版权保护,应仅用于内部分析与研究参考,不得直接用于商业复制或产生混淆。3. <strong>控制访问频率,避免造成负担</strong>:过于密集的请求可能导致对方服务器过载,构成“拒绝服务攻击”(DoS)风险。4. <strong>查看服务条款</strong>:部分网站的用户协议中明确禁止自动化抓取。尽管API是强大工具,但务必在法律和道德框架内审慎使用。</p> <hr> <p class=article><strong>问题九:除了基础的TDK三要素,高级的API还能抓取哪些对SEO有价值的扩展元数据?</strong></p> <p class=article>进阶的API或自建解析程序可以进一步挖掘:1. <strong>Open Graph 标签</strong>:如og:title, og:description,用于社交媒体分享优化。2. <strong>结构化数据(Schema Markup)</strong>:如JSON-LD格式中的产品信息、文章发布日期、评分等,直接影响富媒体搜索结果的展示。3. <strong>H1标签</strong>:虽然非元标签,但作为页面主标题,对SEO至关重要。4. <strong>Canonical 标签</strong>:用于分析网站如何处理重复内容。抓取并分析这些扩展数据,能让您对页面的SEO全貌有更立体的认知,制定更全面的优化策略。</p> <hr> <p class=article><strong>问题十:对于技术基础薄弱的中小企业或个人站长,有没有更便捷的TDK抓取替代方案?</strong></p> <p class=article>当然有。如果不想接触代码,可以考虑:1. <strong>SEO浏览器插件</strong>:如“SEOquake”、“MozBar”等,安装后访问任何网页都能一键显示其TDK信息,适合小规模、手动分析。2. <strong>在线批量查询工具</strong>:部分SEO平台提供有限数量的免费批量TDK查询功能,上传URL列表即可获取。3. <strong>桌面端SEO软件</strong>:一些综合型SEO工具(如Screaming Frog的爬虫模式)在抓取网站结构时,会同步提取每个页面的TDK并生成报告。这些方案门槛较低,但灵活性和大规模自动化处理能力通常不及API。</p> <hr> <p class=article>综上所述,TDK抓取API绝非一个冰冷的技术术语,而是连接数据洞察与SEO实战的关键桥梁。通过精准解答上述十个高频问题,我们希望您不仅能掌握工具的使用方法,更能深刻理解其背后的应用逻辑与合规边界。从竞品监控到自我审计,从内容规划到效果追踪,精准应用TDK抓取API,无疑能让您的SEO优化工作如虎添翼,在激烈的搜索排名竞争中,占据更为有利的制高点。真正的优化始于精准的数据,而成于持续、明智的行动。</p> </div> <div class="amethyst-article-navigation"> <div class="amethyst-nav-header"> <h3 class="amethyst-nav-title"> <i class="layui-icon layui-icon-prev"></i> 文章导航 </h3> </div> <div class="amethyst-nav-content"> <a href="http://www.zxpumps.cn/article-33141.html" class="amethyst-nav-item amethyst-nav-prev"> <div class="amethyst-nav-direction"> <i class="layui-icon layui-icon-left"></i> 上一篇 </div> <div class="amethyst-nav-article-title">网站TDK抓取API:SEO分析利器...</div> </a> <a href="http://www.zxpumps.cn/article-33158.html" class="amethyst-nav-item amethyst-nav-next"> <div class="amethyst-nav-direction"> 下一篇 <i class="layui-icon layui-icon-right"></i> </div> <div class="amethyst-nav-article-title">《图标获取API上线:快速提取favicon新方案》...</div> </a> </div> </div> <footer class="amethyst-article-footer"> <div class="amethyst-article-actions"> <button type="button" class="amethyst-action-btn amethyst-like-btn" id="likeBtn"> <i class="layui-icon layui-icon-praise"></i> <span class="amethyst-action-text">点赞</span> <span class="amethyst-action-count">0</span> </button> <button type="button" class="amethyst-action-btn amethyst-comment-btn" id="commentBtn"> <i class="layui-icon layui-icon-dialogue"></i> <span class="amethyst-action-text">评论</span> </button> <button type="button" class="amethyst-action-btn amethyst-share-btn" id="shareBtn"> <i class="layui-icon layui-icon-share"></i> <span class="amethyst-action-text">分享</span> </button> </div> <div class="amethyst-article-info"> <div class="amethyst-update-time"> 最后更新:2026-10-08 19:53:42 </div> <div class="amethyst-article-tags"> <span class="amethyst-tag">API接口</span> </div> </div> </footer> </article> <section class="amethyst-related-section"> <div class="amethyst-section-header"> <h2 class="amethyst-section-title"> <i class="layui-icon layui-icon-template"></i> 相关推荐 </h2> </div> <div class="amethyst-related-grid"> <a href="http://www.zxpumps.cn/article-33158.html" class="amethyst-related-item" title="《图标获取API上线:快速提取favicon新方案》"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">《图标获取API上线:快速提取favicon新方案》...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:53:42</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="http://www.zxpumps.cn/article-33157.html" class="amethyst-related-item" title="网站ICO图标获取API:快速提取favicon"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">网站ICO图标获取API:快速提取favicon...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:41:09</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="http://www.zxpumps.cn/article-33156.html" class="amethyst-related-item" title="百度权重API-关键词与流量精准评测利器"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">百度权重API-关键词与流量精准评测利器...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:31:07</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="http://www.zxpumps.cn/article-33155.html" class="amethyst-related-item" title="百度权重查询API小时报"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">百度权重查询API小时报...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:20:16</span> <span><i class="layui-icon layui-icon-read"></i>0</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="http://www.zxpumps.cn/article-33154.html" class="amethyst-related-item" title="百度权重查询API包含哪些评估维度?"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">百度权重查询API包含哪些评估维度?...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:10:00</span> <span><i class="layui-icon layui-icon-read"></i>1</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> <a href="http://www.zxpumps.cn/article-33153.html" class="amethyst-related-item" title="百度权重查询:关键词与流量评估API"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">百度权重查询:关键词与流量评估API...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-10-08 19:09:46</span> <span><i class="layui-icon layui-icon-read"></i>1</span> </div> </div> <div class="amethyst-related-arrow"> <i class="layui-icon layui-icon-right"></i> </div> </a> </div> </section> <section class="amethyst-comments-section" id="commentsSection" style="display: none;"> <div class="amethyst-section-header"> <h3 class="amethyst-section-title"> <i class="layui-icon layui-icon-dialogue"></i> 评论区 </h3> </div> <div class="amethyst-comment-form"> <textarea class="amethyst-comment-textarea" placeholder="写下你的想法..."></textarea> <div class="amethyst-comment-actions"> <button type="button" class="amethyst-comment-submit">发表评论</button> </div> </div> <div class="amethyst-comments-list"> <div class="amethyst-no-comments"> <i class="layui-icon layui-icon-face-smile"></i> <p>暂无评论,快来抢沙发吧!</p> </div> </div> </section> </main> </div> </div> </div> <div class="amethyst-share-overlay" id="shareOverlay"></div> <div class="amethyst-share-popup" id="sharePopup"> <div class="amethyst-share-header"> <h3 class="amethyst-share-title">分享文章</h3> <button class="amethyst-share-close" id="shareClose"> <i class="layui-icon layui-icon-close"></i> </button> </div> <div class="amethyst-share-content"> <div class="amethyst-share-buttons"> <div class="amethyst-share-btn" id="shareWeibo"> <i class="layui-icon layui-icon-share"></i> <span>微博</span> </div> <div class="amethyst-share-btn" id="shareQQ"> <i class="layui-icon layui-icon-dialogue"></i> <span>QQ空间</span> </div> <div class="amethyst-share-btn" id="shareWechat"> <i class="layui-icon layui-icon-cellphone"></i> <span>微信</span> </div> <div class="amethyst-share-btn" id="shareQzone"> <i class="layui-icon layui-icon-friends"></i> <span>QQ好友</span> </div> </div> <div class="amethyst-share-url-section"> <div class="amethyst-share-url" id="shareUrl">http://www.zxpumps.cn/article-33142.html</div> <button class="amethyst-share-copy" id="shareCopy">复制链接</button> </div> </div> </div> <link rel="stylesheet" type="text/css" href="http://www.zxpumps.cn/template/article12/assets/css/foot.css" /> <div class="amethyst-friend-links-section"> <div class="amethyst-friend-links-container"> <div class="amethyst-friend-links-header"> <h3 class="amethyst-friend-links-title"> <i class="layui-icon layui-icon-link"></i> 友情链接 </h3> <p class="amethyst-friend-links-desc">与优秀的网站建立友好合作关系,共同发展进步</p> </div> <div class="amethyst-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="amethyst-footer"> <div class="amethyst-footer-container"> <div class="amethyst-footer-content"> <div class="amethyst-footer-main"> <div class="amethyst-footer-brand"> <a href="http://www.zxpumps.cn/" class="amethyst-footer-logo"> <i class="layui-icon layui-icon-home"></i> <span>163网址导航网</span> </a> <p class="amethyst-footer-desc"> 致力于为用户提供优质的内容和服务,打造专业的知识分享平台。我们相信知识的力量,让每一次访问都有所收获。 </p> </div> <div class="amethyst-footer-social"> <span class="amethyst-social-text">关注我们</span> <div class="amethyst-social-links"> <a href="#" class="amethyst-social-link" title="微信"> <i class="layui-icon layui-icon-chat"></i> </a> <a href="#" class="amethyst-social-link" title="QQ"> <i class="layui-icon layui-icon-dialogue"></i> </a> <a href="#" class="amethyst-social-link" title="邮箱"> <i class="layui-icon layui-icon-email"></i> </a> <a href="#" class="amethyst-social-link" title="GitHub"> <i class="layui-icon layui-icon-github"></i> </a> </div> </div> </div> <div class="amethyst-footer-bottom"> <div class="amethyst-footer-copyright"> <span class="amethyst-copyright-text"> CopyRight © 2024-2026 163网址导航网 All Rights Reserved. </span> </div> </div> </div> </div> </footer> <div class="amethyst-back-to-top" id="amethystBackToTop"> <i class="layui-icon layui-icon-up"></i> </div> <div class="amethyst-back-to-bottom" id="amethystBackToBottom"> <i class="layui-icon layui-icon-down"></i> </div> <div class="amethyst-progress-bar"> <div class="amethyst-progress-fill"></div> </div> <canvas id="amethystCanvas" class="amethyst-canvas"></canvas> <script src="http://www.zxpumps.cn/assets/layui/layui.js"></script> <script src="http://www.zxpumps.cn/assets/js/jquery/1.12.4/jquery.min.js"></script> <script> $(document).ready(function() { var $mobileMenuBtn = $('#amethystMobileMenuBtn'); var $mobileNav = $('#amethystMobileNav'); var $mobileCloseBtn = $('#amethystMobileCloseBtn'); var $mobileNavOverlay = $('.amethyst-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'); } ); $('.amethyst-social-link').hover( function() { $(this).addClass('social-hover'); }, function() { $(this).removeClass('social-hover'); } ); var $backToTop = $('.amethyst-back-to-top'); var $backToBottom = $('.amethyst-back-to-bottom'); if ($backToTop.length === 0) { $backToTop = $('<div class="amethyst-back-to-top"><i class="layui-icon layui-icon-up"></i></div>'); $body.append($backToTop); } if ($backToBottom.length === 0) { $backToBottom = $('<div class="amethyst-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; $('.amethyst-progress-fill').css('width', progress + '%'); }); $(window).trigger('scroll'); var canvas = document.getElementById('amethystCanvas'); 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(155, 89, 182, ' + this.life + ')'; } Particle.prototype.update = function() { this.x += this.vx; this.y += this.vy; this.life -= this.decay; this.color = 'rgba(155, 89, 182, ' + 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); }); } $('.amethyst-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('.amethyst-action-count'); var currentLikes = parseInt($count.text()); $.ajax({ type: 'POST', url: 'http://www.zxpumps.cn/ajax.php?act=dianzan', data: {id:'33142',type:2}, dataType : 'json', success:function(result){ if (result.code !==200) { return layer.msg(result.msg, {anim:6,time:1500}); } $btn.addClass('amethyst-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('amethyst-no-scroll'); }); function closeSharePopup() { $('#shareOverlay, #sharePopup').removeClass('show'); $('body').removeClass('amethyst-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('SEO优化利器:TDK抓取API的精准应用案例 - 163网址导航网'); $('#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(); }); $('.crystal-comment-submit').on('click', function() { var commentText = $('.crystal-comment-textarea').val().trim(); if (commentText === '') { layer.msg('请输入评论内容', {icon: 2, time: 2000}); return; } layer.msg('评论提交成功!', {icon: 1, time: 2000}); $('.crystal-comment-textarea').val(''); }); function generateTOC() { var $content = $('.crystal-article-content'); var $tocContent = $('#tocContent'); var headings = $content.find('h1, h2, h3, h4, h5, h6'); if (headings.length > 0) { var tocHtml = '<ul class="crystal-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="crystal-toc-item crystal-toc-level-' + level + '">'; tocHtml += '<a href="#' + id + '" class="crystal-toc-link">' + title + '</a>'; tocHtml += '</li>'; }); tocHtml += '</ul>'; $tocContent.html(tocHtml); } } generateTOC(); var $sidebar = $('.crystal-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>