Using fopen function to collect news page content and save it to local function

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags code content echo file function get http local

?
//PHP News crawl by Neil Moomey.
//You are free to use this code as your wish.
//Please make sure you can get permission from the title from any website you grab.
//You may need to write the title on your server to speed up the file.

//grab from File or Web page source code site
if (!) ( $myFile =fopen (http://www.jzread.com, "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);
//Unzip the beginning and end of everything. You need to include these lines
///Choose some unique sub in the title or select the beginning of the HTML celebration
//And the news is over.


$start = "<hr align=";
$end = "Establish mirror";
$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;
?>

Related Article

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.