网站ICO图标一键提取API,快速获取favicon

许多网络开发者和数据分析师在日常工作中,都曾遇到过需要快速获取网站favicon图标的情况。无论是用于制作书签管理器、丰富数据分析仪表板的视觉效果,, 还是进行品牌识别研究,一个高效可靠的ICO图标提取API都显得至关重要。为此,我们精心整理了用户最为关心的十个高频问题,并提供了深度解答与实操步骤,助您轻松实现一键提取。


**问题一:什么是网站favicon图标?为什么我需要通过API来提取它?** 网站favicon(即“favorites icon”的缩写)是显示在浏览器标签页、书签栏以及历史记录列表旁的一个小型标志性图标。它不仅是品牌身份的重要视觉元素,也能提升用户体验的专业度和一致性。 手动保存favicon费时费力,尤其当您需要批量处理成百上千个网站时。通过专用的API进行一键提取,可以自动化这一流程,将获取、下载和格式转换集成到您的应用程序或脚本中, 极大提升工作效率,并确保获取的图标是最新且准确的。
**问题二:如何判断一个网站是否存在favicon,以及它可能存放在哪些位置?** 在尝试提取前,了解favicon的存放位置是关键。通常,网站会通过以下几种方式声明其favicon: 1. 在HTML文档的部分使用 标签指定。 2. 将图标直接放置在网站根目录下,命名为 favicon.ico。 3. 使用PNG、GIF或SVG格式,并通过rel="icon"链接指明。 因此,一个健壮的提取API会模拟浏览器行为,系统地检查这些常见位置:首先解析HTML以查找link标签,如果未找到,则依次尝试访问/favicon.ico、/favicon.png等默认路径,直到成功获取或确认不存在。
**问题三:市面上的一键提取API通常支持哪些输出格式?我能获取到原尺寸的高清图标吗?** 专业的API服务通常会提供灵活的格式输出选项。最常见的输出格式包括原生的ICO、以及更通用的PNG、JPG和WebP。这确保了提取的图标能够适应不同的使用场景,如移动应用、桌面软件或网页嵌入。 关于图标尺寸,一个优质的API会尽力获取源站提供的最高质量、最大尺寸的图标文件。许多现代网站会为高分辨率屏幕提供32x32、64x64甚至128x128像素的图标。您的提取请求应能返回这些原始文件, 部分API还可能提供额外的缩放或裁剪功能,以满足您的特定尺寸需求。
**问题四:如果我需要批量处理大量网站的favicon,API有相应的批量调用或并发处理方案吗?** 对于批量处理需求,选择支持批量操作的API是核心。这类API通常提供两种方案: 1. **批量端点(Batch Endpoint)**:您可以一次性通过一个API请求提交最多数十个甚至数百个网址,API会并行处理并返回一个包含所有结果的集合。 2. **高并发限制**:即使没有专用的批量端点,如果API允许较高的每秒请求数(QPS)限制,您也可以在自己的代码中实现多线程或异步调用,从而快速处理列表。 在实操时,请务必查阅API文档,了解其批量功能的用法、限制(如每批的最大数量),并注意遵守其服务条款,避免对目标网站造成过大压力。
**问题五:在提取过程中,如何处理可能遇到的错误,例如网站无法访问、404错误或根本没有favicon的情况?** 一个可靠的API应具备完善的错误处理机制。当出现异常时,它不应简单地崩溃,而应返回结构化的错误信息。常见的处理方式包括: * **返回明确的HTTP状态码**:如404表示未找到favicon,408表示请求目标网站超时,502表示网关错误等。 * **提供友好的错误信息字段**:在JSON响应体中,除了success: false标志外,还应包含error_code和message,例如 {"error_code": "ICON_NOT_FOUND", "message": "No favicon could be located at the provided URL."}。 * **提供降级方案或默认图标**:某些API在无法获取图标时,可以选择返回一个预设的默认图标,确保您的应用程序界面不会因为缺少图片而断裂。
**问题六:从隐私和安全角度考虑,使用此类API提取图标是否存在风险?如何规避?** 安全与隐私是重中之重。使用第三方API时,请注意: * **数据传输安全**:确保API服务使用HTTPS加密协议,防止您查询的网址列表在传输过程中被窃听。 * **服务商信誉**:选择知名、可信的服务提供商,仔细阅读其隐私政策,确认他们不会记录或滥用您提交的查询数据。 * **本地化处理**:对于敏感的内部网址,最安全的方案是自行搭建或使用可本地部署的开源提取脚本,确保所有请求不经过外部服务器。
**问题七:API的响应速度如何?有哪些因素会影响提取速度?** API的响应速度通常在几百毫秒到几秒之间。影响速度的主要因素包括: 1. **目标网站的响应速度**:如果目标服务器本身加载缓慢,API等待其返回HTML或图标文件的时间就会变长。 2. **图标查找策略的复杂性**:如前所述,API可能需要尝试多个位置才能找到图标,步骤越多,耗时可能越长。 3. **网络延迟**:API服务器与目标网站服务器之间的物理距离和网络质量。 4. **API服务商的内部架构**:优秀的服务商会使用全球CDN节点和高效的缓存策略来加速响应。 在测试时,您可以对国内、国外不同地域的网站进行采样请求,以评估API在实际应用中的平均性能。
**问题八:我能通过API获取到不是方形或不是标准尺寸的favicon吗?如何处理这些非标准图标?** 是的,完全有可能遇到非标准图标。有些网站会使用长方形(如16x32像素)或尺寸奇特的图标。一个强大的API会原样返回这些图标文件。在您的应用程序中处理时,需要考虑前端展示的兼容性。 通用解决方案是:在接收到图标后,使用图像处理库(如PIL for Python, Sharp for Node.js, GD for PHP)进行后处理,将其居中缩放或裁剪到您需要的统一尺寸,并添加透明或背景填充,以确保显示美观一致。
**问题九:如果目标网站使用了动态favicon(例如会变化的数字或颜色),API会提取到哪一个状态?** 这是一个高级且有趣的问题。动态favicon通常是通过JavaScript实时修改标签的href属性来实现的。大多数提取API的工作方式是获取初始的HTML文档并查找图标链接,它们**不会**执行页面中的JavaScript。 因此,API提取到的通常是页面加载初期、JS执行前的那个初始/默认状态的favicon。如果您需要获取特定动态状态下的图标,可能需要结合无头浏览器(如Puppeteer)工具,在页面完全渲染并达到所需状态后再进行截图或资源捕获。
**问题十:除了简单的提取,此类API还能提供哪些增值功能或数据?** 现代favicon提取API已不仅限于返回一个图像文件。它们可能提供丰富的增值数据,例如: * **图标元数据**:返回图标的格式、尺寸、文件大小等信息。 * **多尺寸预览**:提供同一图标不同尺寸版本的链接。 * **网站基础信息**:结合图标提取,附带返回网站的标题()、描述等基础元信息。 * **缓存与CDN加速**:提供长期稳定的图标缓存链接,您可以直接引用该链接而无需再次下载,既节省流量又提升终端用户加载速度。 在选择API时,可以对比不同服务商的功能列表,这些增值功能能进一步简化您的开发流程。 <hr> **扩展问答:如何处理老旧网站使用的.ico文件包含多个尺寸的问题?** 传统的ICO文件是一种容器格式,可以内含多个不同尺寸(如16x16, 32x32, 48x48)和色深的小图标。当API返回一个多图标的ICO文件时,您需要根据使用场景选择合适尺寸。 在编程处理时,可以使用专门的库(如python-icoextract)来解析ICO文件,枚举其中的所有图像,然后按需选择最大尺寸或最匹配您需求的图标进行使用。 <hr> **扩展问答:对于反爬机制严格的网站,API如何成功提取favicon?** 面对有反爬策略的网站,专业API服务商会采用一系列合规技术来模拟合法浏览器的请求,例如设置真实的User-Agent头部、管理Cookie会话、添加合理的请求间隔等。 但必须强调的是,所有操作都应在尊重robots.txt协议和目标网站服务条款的前提下进行。作为用户,您应确保使用API的目的和频率是合理且合法的。 <hr> 通过以上十个核心问题及扩展内容的深度解析,相信您对网站favicon一键提取API的工作原理、应用场景和高级技巧都有了全面了解。正确利用这些工具和服务,将能显著优化您的项目流程,让图标获取变得前所未有的简单高效。</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="https://7icp.cn/icp/25814.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">网站ICO图标API:一键提取favicon,快速获取工具...</div> </a> <a href="https://7icp.cn/icp/25821.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:实时网页内容快速保存...</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-09-24 01:29:28 </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="https://7icp.cn/icp/25821.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-09-24 01:29:28</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="https://7icp.cn/icp/25820.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-09-24 01:29:37</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="https://7icp.cn/icp/25819.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-09-24 01:24:35</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="https://7icp.cn/icp/25818.html" class="amethyst-related-item" title="网页秒变截图,高效保存真方便"> <div class="amethyst-related-content"> <h3 class="amethyst-related-title">网页秒变截图,高效保存真方便...</h3> <div class="amethyst-related-meta"> <span><i class="layui-icon layui-icon-time"></i>2026-09-24 01:22:26</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="https://7icp.cn/icp/25817.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-09-24 01:10:14</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="https://7icp.cn/icp/25816.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-09-24 00:49:39</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> </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">https://7icp.cn/icp/25815.html</div> <button class="amethyst-share-copy" id="shareCopy">复制链接</button> </div> </div> </div> <link rel="stylesheet" type="text/css" href="https://7icp.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="https://7icp.cn/" class="amethyst-footer-logo"> <i class="layui-icon layui-icon-home"></i> <span>ICP备案查询网</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 © 2021-2026 ICP备案查询网 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="https://7icp.cn/assets/layui/layui.js"></script> <script src="https://7icp.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: 'https://7icp.cn/ajax.php?act=dianzan', data: {id:'25815',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('网站ICO图标一键提取API,快速获取favicon - ICP备案查询网'); $('#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>