How to crawl the "window of Shenzhen" News _php Tutorial

Source: Internet
Author: User
Recently many netizens came to ask me how to use PHP to crawl other web site news, I began to worry about infringement, has not been public. But asked too many people, here I give an example----how to crawl "Shenzhen window" news, for everyone to refer to the use of ideas. Please be aware that you do not violate the rules. Thank you.
Crawl "Tech News" Catalog code page (readnews.php):
$url = "http://news.szptt.net.cn/kjxw.phtml";
if (Isset ($url) && $url! = "") {
$str = Implode ("", File ($url));
$str _ary = Explode ("
    ", $STR);
    $str _ary = Explode ("", $str _ary[1]);
    for ($i =0; $i <15; $i + +) {
    echo $str _ary[$i];
    }
    }
    ?>


    Related articles
    ? How to crawl the "windows of Shenzhen" news
    Recently many netizens came to ask me how to use PHP to crawl other web site news, I began to worry about infringement, has not been public. But asked too many people, here I give an example----how to crawl "Shenzhen window" news, for everyone to refer to the use of ideas. Please be aware that you do not violate the rules. Thank you.

    Crawl "tech News" detail code page (readnewsdetail.php):
    <title>Ctohome.com Technology news Channel</title>
    /*
    * Ctohome.com Shenzhen News
    */
    $url _ary = Explode ("/", $url);
    $url = $url _ary[count ($url _ary)-2]. "/" . $url _ary[count ($url _ary)-1];
    $url = "http://news.szptt.net.cn/". $url;
    if (Isset ($url) && $url! = "") {
    $str = Implode ("", File ($url));
    $str _ary = Explode (" ";
    for ($i =4; $i <6; $i + +) {
    echo " }
    Echo "


    http://www.bkjia.com/phpjc/532204.html www.bkjia.com true http://www.bkjia.com/phpjc/532204.html techarticle recently many netizens to ask me how to use PHP to crawl other web site news, I began to worry about infringement, has not been public. But there are too many people to ask, here I give an example----how to crawl "...

  • echo" "; } ?> The method to crawl depends on the different original code, before you carefully analyze the page you want to crawl HTML original code, and then find the rules, and finally write code. IE has a strong error-correcting function for HTML syntax, so as long as the display results are correct, there are some grammatical errors in the crawled code.

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.