• 技术文章 >后端开发 >php教程

    新闻捕捉器php_PHP教程

    2016-07-13 17:23:59原创294
    // PHP Headlines Grabber by Neil Moomey, www.neilmoomey.com.
    // You are free to use this code as you wish.
    // Make sure you get permission from any web sites you grab headlines from.
    // You may want to write the headlines to a file on your server to speed things up.

    // Grab source code from a file or web site
    if(!($myFile=fopen("http://www.lndaily.com.cn/web/yw3.htm","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);
    // Extract everything between start and end. You need to include these lines
    //in the headlines or pick some unique substring in the html to mark the start
    //and end of the news.
    $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;
    ?>

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532178.htmlTechArticle// PHP Headlines Grabber by Neil Moomey, www.neilmoomey.com. // You are free to use this code as you wish. // Make sure you get permission from any web sites you grab headlines fro...

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:新闻 捕捉 php PHP Headlines Grabber Neil Moomey www.neilmoomey
    上一篇:php同时提取多条新闻中的文本一例_PHP教程 下一篇:php图库程序上传就可以使用_PHP教程
    Web大前端开发直播班

    相关文章推荐

    • php反序列化实例详解之字符串逃逸• 一文带你PHP利用phpmailer实现邮件发送功能• 什么是PHPUnit?在PHP项目中怎么使用?• [转一篇比较老的文章]编写自己的php扩展函数_PHP• Windows 下 PHP 环境的配置

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网