欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

使用 jsoup 从 HTML 中提取所有链接的例子

程序员文章站 2022-03-31 22:28:15
...
字节顺序记号(英:byte-order mark,BOM)是位于码点 U+FEFF 的统一码字符("零宽度无断空白")。当以 UTF-16 或 UTF-32 来将UCS/统一码字符所组成的字串编码时,这个字符被用来标示其字节序。它常被用来当做标示文件是以 UTF-8 、 UTF-16 或 UTF-32 编码的记号。
  1. class cryption {
  2. function en($str,$key) {
  3. $ret='';
  4. $str = base64_encode ($str);
  5. for ($i=0; $i $d_str=substr($str, $i, 1);
  6. $int =ord($d_str);
  7. $int=$int^$key;
  8. $hex=strtoupper(dechex($int));
  9. $ret.=$hex;
  10. }
  11. return $ret;
  12. }
  13. function de($str,$key) {
  14. $ret='';
  15. for ($i=0; $i $hex=substr($str, $i, 2);
  16. $dec=hexdec($hex);
  17. $dec=$dec^$key;
  18. $ret.=chr($dec);
  19. $i=$i+2;
  20. }
  21. return base64_decode($ret);
  22. }
  23. }
  24. $cryption=new cryption;
  25. ?>
复制代码
  1. /*
  2. * Created on 2012-3-23
  3. *
  4. * To change the template for this generated file go to
  5. * Window - Preferences - PHPeclipse - PHP - Code Templates
  6. */
  7. $content = '
    使用 jsoup 从 HTML 中提取所有链接的例子
    ';
  8. preg_match('/使用 jsoup 从 HTML 中提取所有链接的例子]*src=["\']屁屁[\/]?(.+?)["\']屁屁[^>]*>/si', $content, $matches);
  9. print_r($matches);
  10. echo '
    ';
  11. preg_match('/使用 jsoup 从 HTML 中提取所有链接的例子]*src=["\']屁屁[\/]?(.+?)["\']屁屁[^>]*>/si', $content, $matches);
  12. print_r($matches);
  13. define('HTTP_PATH','http://'.$_SERVER['HTTP_HOST']);
  14. $img = getimagesize(HTTP_PATH.$matches[1]);
  15. print_r($img);
  16. mb_internal_encoding('UTF-8');
  17. $a = '我爱你 I love you';
  18. echo mb_strlen($a);
  19. echo '
    ';
  20. echo mb_substr($a,1,2);
  21. ?>
复制代码
  1. // +----------------------------------------------------------------------
  2. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  7. // +----------------------------------------------------------------------
  8. // | Author: liu21st
  9. // +----------------------------------------------------------------------
  10. // 定义ThinkPHP框架路径
  11. define('THINK_PATH', 'ThinkPHP');
  12. //定义项目名称和路径
  13. define('APP_NAME', 'Home');
  14. define('APP_PATH', 'Home');
  15. define('NO_CACHE_RUNTIME', true);
  16. //define('RUNTIME_ALLINONE', true);
  17. // 加载框架入口文件
  18. require(THINK_PATH."/ThinkPHP.php");
  19. //实例化一个网站应用实例
  20. App::run();
  21. ?>
复制代码
使用 jsoup 从 HTML 中提取所有链接的例子