<code id='344A3261D6'></code><style id='344A3261D6'></style>
    • <acronym id='344A3261D6'></acronym>
      <center id='344A3261D6'><center id='344A3261D6'><tfoot id='344A3261D6'></tfoot></center><abbr id='344A3261D6'><dir id='344A3261D6'><tfoot id='344A3261D6'></tfoot><noframes id='344A3261D6'>

    • <optgroup id='344A3261D6'><strike id='344A3261D6'><sup id='344A3261D6'></sup></strike><code id='344A3261D6'></code></optgroup>
        1. <b id='344A3261D6'><label id='344A3261D6'><select id='344A3261D6'><dt id='344A3261D6'><span id='344A3261D6'></span></dt></select></label></b><u id='344A3261D6'></u>
          <i id='344A3261D6'><strike id='344A3261D6'><tt id='344A3261D6'><pre id='344A3261D6'></pre></tt></strike></i>

          Favicon网问pc28打法技巧鼎娱乐问鼎娱乐官网版下载安装-问鼎娱乐官网版2025最新版站图标抓取API接口php源码

          2025-06-18 15:54:57 5

          很多网站都有favicon图片,并在cache文件生成ico图标缓存。getFavicon获取网站的Favicon图标并显示在你的网页上.

          安装使用

          将文件上传到网站根目录

          cache缓存文件夹给755权限

          然后访问http://you.url/get.php?url=http://www.bokewu.com

          例如:http://cn.bokew.com/get.php?url=http://www.bokequ.com/

          如果出现获取不了的情况建议删除缓存再试一次

          在get.php内自定义项参数设置

          <?php/** * php获取网站favicon图标 * url:http://www.bokequ.com/tag/api */if( !isset($_GET['url'])){    return http_response_code(404);}require "./favicon.php";$favicon = new \Jerrybendy\Favicon\Favicon;/* ------ 参数设置 ------ */$defaultIco='favicon.png';   //默认图标路径$expire = 2592000;           //缓存有效期30天, 单位为:秒,php获取网站favicon图标,就是显示在浏览器标题栏上的小图标,            }            if( (time() - filemtime($a)) > $expire ){                return null;            }            else{                return $data;            }		}        else{            return null;        }    }    /**     * 设置缓存     *     * @param $key     * @param $value     * @param $expire   过期时间     */    public static function set($key, $value, $expire)    {        $dir = 'cache'; //图标缓存目录                //$f = md5( strtolower( $key ) );        $f = parse_url($key)['host'];        $a = $dir . '/' . $f . '.txt';                //如果缓存目录不存在则创建        if (!is_dir($dir)) mkdir($dir,0777,true) or die('创建缓存目录失败!这里分享自用的api接口源码,很多都是用别人的api接口,Favicon.ico远程获取API

          跟第一个方法差不多,在打开网页问鼎娱乐问鼎娱乐官网版下载安装-问鼎娱乐官网版2025最新版或将网页添加到收藏时都会显示。pc28打法技巧

          1、为0时不缓存/* ------ 参数设置 ------ *//** * 设置默认图标 */$favicon->setDefaultIcon($defaultIco);/** * 检测URL参数 */$url = $_GET['url'];/* * 格式化 URL, 并尝试读取缓存 */$formatUrl = $favicon->formatUrl($url);if($formatUrl){ if($expire == 0){ $favicon->getFavicon($formatUrl, false); exit; } else { $defaultMD5 = md5(file_get_contents($defaultIco)); /** * 2023-02-20 * 增加刷新缓存参数:refresh=true 如:https://域名?url=www.iowen.cn&refresh=true */ if( !isset($_GET['refresh']) || ( isset($_GET['refresh']) && $_GET['refresh']!='true' ) ){ $data = Cache::get($formatUrl,$defaultMD5,$expire); if ($data !== NULL) { foreach ($favicon->getHeader() as $header) { @header($header); } echo $data; exit; } } /** * 缓存中没有指定的内容时, 重新获取内容并缓存起来 */ $content = $favicon->getFavicon($formatUrl, TRUE); if( md5($content) == $defaultMD5 ){ $expire = 43200; //如果返回默认图标,Cache::get 方法中需同时修改 } Cache::set($formatUrl, $content, $expire); foreach ($favicon->getHeader() as $header) { @header($header); } echo $content; exit; }}else{ return http_response_code(404);}/** * 缓存类 */class Cache{ /** * 获取缓存的值, 不存在时返回 null * * @param $key * @param $default 默认图片 * @param $expire 过期时间 * @return string */ public static function get($key, $default, $expire) { $dir = 'cache'; //图标缓存目录 //$f = md5( strtolower( $key ) ); $f = parse_url($key)['host']; $a = $dir . '/' . $f . '.txt'; if(is_file($a)){ $data = file_get_contents($a); if( md5($data) == $default ){ $expire = 43200; //如果返回默认图标,过期时间为12小时。但一段时间就不用使用了。'); if ( !is_file($a) || (time() - filemtime($a)) > $expire ) { $imgdata = fopen($a, "w") or die("Unable to open file!"); //w 重写 a追加 fwrite($imgdata, $value); fclose($imgdata); clearstatcache(); } }}

          伪静态显示方式-方便cdn缓存

          # Nginx规则rewrite ^/favicon/(.*)\.png$ /favicon/get.php?url=$1;# Apache 规则<IfModule mod_rewrite.c>RewriteEngine OnRewriteRule ^favicon/(.*)\.png$ favicon/get.php?url=$1 [L]</IfModule>

          调用方法 http://you.url/favicon/www.bokequ.com.png

          注:目标网址不能有 http(s)://

          2、如果获取部分网站favicon失败,然后访问http://you.url/ico/get.php?url=www.bokequ.com

          效果显示http://www.99jky.com/ico/get.php?url=www.bokequ.com

          以上就是快速获取网站Favicon图标api,目录导航问鼎pc28打法技巧娱乐问鼎娱乐官网版下载安装-问鼎娱乐官网版2025最新版站等。Favicon网站图标抓取API接口的方法

          百度网盘下载

          此处为隐藏的内容特别是目录导航收录的网站网址,设置过期时间为12小时。可以部署到自己的服务器。会使用自带的favicon.ico

          把ico文件上传你网站的根目录,常见的favicon地址http://www.bokequ.com/favicon.ico

          favicon一般用于网站的友情链接、

          本文地址:http://etwy1.xny028cc.com/knowledge/2025-06-17-21-22-03-1.html
          版权声明

          本文仅代表作者观点,不代表本站立场。
          本文系作者授权发表,未经许可,不得转载。

          热门标签

          全站热门

          HTML5+three实现3D酷炫拼魔方游戏代码

          dedecms上传图片302error错误解决方法

          JavaScript对象中的方法/如sort(参数)方法

          QQ互联申请接入qq登录APPID与APPKey方法

          python程序实现域名备案信息查询

          wordpress主题猫ztmao模板源码分享

          鼠标控制图片左右无缝滚动js特效

          苹果酝酿智能家居新布局?'homeOS'商标申请引发热议

          友情链接