Php: simple code for reading html and intercepting strings _ PHP Tutorial

Source: Internet
Author: User
Php reads html and captures the simple code of a string. Copy the code as follows :? Php $ title script home; $ hellojb51.net !; $ Filefile_get_contents (www.baidu.com); $ fileiconv (gbkIGNORE, UTF-8, $ file); echo $ file; The code is as follows:


$ Title = 'foot home ';
$ Hello = 'jb51. net! ';
$ File = file_get_contents ('http: // www.baidu.com ');
$ File = iconv ("gbk // IGNORE", "UTF-8", $ file );
// Echo $ file;
Echo strpos ($ file ,''); <BR> echo substr ($ file, strpos ($ file,' <title> ') + 7, strpos ($ file ,''-Strpos ($ file ,'') + 7 ));
$ File = str_replace (array ('Baidu review ',' {hello} '), array ($ title, $ hello), $ file );
?>


The following is the program code of the thieves used by Yuhai. For more information, see. The script home provides a variety of thieves.

The code is as follows:


Function _ url ($ Date ){
$ Ch = curl_init ();
$ Timeout = 5;
Curl_setopt ($ ch, CURLOPT_URL, "$ Date ");
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 )");
Curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout );
$ Contents = curl_exec ($ ch );
Curl_close ($ ch );
Return $ contents;
}
$ Url = "http://www.jb51.net ";
$ Contents. = _ url ($ url );
Echo $ contents; // Output Content
?>

The http://www.bkjia.com/PHPjc/320996.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320996.htmlTechArticle code is as follows :? Php $ title = 'foot home'; $ hello = 'jb51. net! '; $ File = file_get_contents ('http: // www.baidu.com'); $ file = iconv ("gbk // IGNORE", "UTF-8", $ file ); // echo $ file ;...

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.