Baidu Thief: _php tutorial on removing bids and advertisements

Source: Internet
Author: User
function title.
Rewrite rules are consistent with WordPress.
Compatible with IIS, Apache, Nginx.
Only one file implements all functions.

 
 
  1. PHP
  2. if (Isset ($_GET[WD])) {
  3. $ keywords = $_get[wd];
  4. }
  5. $ URI = isset ($_server[http_x_rewrite_url])? $_server[http_x_rewrite_url]: $_server[request_uri];
  6. $ content = file_get_contents ("http://www.baidu.com". $uri);
  7. if ($uri==/| | empty ($uri)) {
  8. Display ($content);
  9. }
  10. Delete "to Baidu promotion" link
  11. $ Start = Preg_quote ("<Div class=" R ec_bdtg "> ");
  12. $ content = Preg_replace ("/". $start. " ((?! < BR > ).) *<br>"." /is ", $content);
  13. Delete Left auction
  14. $ Start = " ).) *> " ;
  15. $ content = Preg_replace_callback ("/". $start. " ((?! < /table > ).) *</table>/is "," Search_result_filter ", $content);
  16. //Delete the remaining multiple < BR >
  17. $ content = Str_ireplace ("<br><br> ",, $content);
  18. //Delete the remaining multiple < BR >
  19. $ content = Str_ireplace ("<br/> ", $content);
  20. Delete Right Promotion link
  21. $ Start = Preg_quote ("<Div id=" Ec_im_container "> ");
  22. $ content = Preg_replace ("/". $start. " ((?! < style ).) *"." /is ","<br /> div>", $ content);
  23. Display ($content);
  24. /**
  25. * Search Results Filter
  26. */
  27. function Search_result_filter ($matches) {
  28. The background #f5f5f5 is the advertisement
  29. if (strpos ($matches [0], "bgcolor=" #f5f5f5 ")) return;
  30. ID4 the number of digits is the advertisement
  31. if (Preg_match ("/<) Table (. *?) ID =\ "(d{4,}) \" (. *?) > ((?! < /table > ).) *</table>/is ", $matches [0])) {
  32. return;
  33. }
  34. return $matches [0];
  35. }
  36. function display ($content) {
  37. Echo $content;
  38. }

http://www.bkjia.com/PHPjc/486023.html www.bkjia.com true http://www.bkjia.com/PHPjc/486023.html techarticle function title. Rewrite rules are consistent with WordPress. Compatible with IIS, Apache, Nginx. Only one file implements all functions. PHP if (isset ($_GET[WD])) {$ keywords =$_get[wd];} $ uri = ...

  • 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.