Use the fopen function to collect news page content and save it to the local function-PHP source code

Source: Internet
Author: User
Ec (2); & lt ;? PHP News captured by NeilMoomey ,. You can use this code as your wish. Please make sure that you can get the title license from any website. You may need to write the title on your server to speed up the file. Grab the source code from a file or webpage. if (! ($ MyFilefopen (www.111cn.net, & quot; r & quot;) {script ec (2); script

  // The PHP news is captured by Neil Moomey ,.
// You can use this code as your wish.
// Make sure that you can get permission from any website and from the title.
// You may need to write the title on your server to speed up the file.

// Grab the source code website from a file or webpage
If (! ($ MyFile = fopen (http://www.111cn.net, "r ")))
{
Echo "The news interface is down for maintenance .";
Exit;
}
While (! Feof ($ myFile ))
{
// Read each line and add to $ myLine
$ MyLine. = fgets ($ myFile, 255 );
}
Fclose ($ myFile );
// Decompress the package between start and end. You need to include these rows
// In the title or select some unique sub-scripts to start celebrating in HTML
// And the news is over.


$ Start ="

$ Start_position = strpos ($ myLine, $ start );
$ End_position = strpos ($ myLine, $ end) + strlen ($ end );
$ Length = $ end_position-$ start_position;
$ MyLine = substr ($ myLine, $ start_position, $ length );
// Display HTML
Echo $ myLine;
?>

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.