PHP thieves on the crawl page different coding solution!

Source: Internet
Author: User
Tags cdata explode
where My_encoding () is converted into the way you want to encode! I novice a little trick master laughed at!
  1. ?
  2. function Get_sub_content ($str, $start, $end) {
  3. if ($start = = ' $end = = ') {
  4. Return page element has changed! ";
  5. }
  6. $str = Explode ($start, $str);
  7. $str = Explode ($end, $str [1]);
  8. return $str [0];
  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= Jay%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, "<div id=\" result\ ">", "<br clear=");
  19. $str _replace = Explode ("<div class=x>", $doc);
  20. echo "<?xml version=\" 1.0\ "encoding=\" utf-8\ "?>";
  21. echo "<data>";
  22. For ($i =1 $i <=count ($str _replace)-1; $i + +) {
  23. echo "<video>";
  24. echo "<name>";
  25. echo "<! [cdata[". Get_sub_content ($str _replace[$i]," title=\ "", "\"). "] > ";
  26. echo "</name>";
  27. echo "<pageurl>";
  28. echo "<! [cdata[. Get_sub_content ($str _replace[$i], "<a href=\" "," \ "onmousedown=").] > ";
  29. echo "</pageurl>";
  30. echo "</video>";
  31. }
  32. echo "</data>";
  33. ?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.