search
Homephp教程php手册PHP小偷 关于抓取页面不同编码的解决方法!

其中my_encoding()是转换成你想要编码的方法!本人新手 一点小伎俩 高手见笑!

  1. function get_sub_content($str, $start, $end){      
  2.  if ( $start == '' $end == '' ){             
  3.   return "页面元素已经改变!";       
  4.   }       
  5.   $str = explode($start, $str);       
  6.   $str = explode($end, $str[1]);       
  7.   return $str[0];
  8.   }
  9.  
  10. function my_encoding($data,$to){
  11.  $encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
  12.  $encoded = mb_detect_encoding($data, $encode_arr);
  13.  $data = mb_convert_encoding($data,$to,$encoded);
  14.  return $data;
  15. }
  16. $doc = file_get_contents("http://video.baidu.com/v?ct=0&word=周杰伦%20site%3Awww%2Etudou%2Ecom&db=0&ty=0&rn=20&pn=0&fbl=1024");
  17. $doc = my_encoding($doc,"utf-8");
  18. $doc =get_sub_content($doc,"
    ","
    ",$doc);
  19. echo "";
  20. echo "";
  21. for ($i=1; $i
  22. echo "
  23. echo "";
  24. echo "";
  25. echo "";
  26. echo "";
  27. echo "";
  28. echo "";
  29. echo "";
  30. }
  31. echo "";
  32. ?>


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!