How to capture the "Shenzhen Window" news

Source: Internet
Author: User
Recently, many netizens have asked me how to use PHP to capture news from other websites. at first, I began to worry about infringement and have never been made public. However, there are too many people to ask. here is an example-how to capture the "Shenzhen Window" news for your reference only. Do not violate regulations. Thank you. Capture "technology SyntaxHighlighter. all ();

Recently, many netizens have asked me how to use PHP to capture news from other websites. at first, I began to worry about infringement and have never been made public. However, there are too many people to ask. here is an example-how to capture the "Shenzhen Window" news for your reference only. Do not violate regulations. Thank you.
Capture the "Tech News" directory 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 capture the "Shenzhen Window" news
    Recently, many netizens have asked me how to use PHP to capture news from other websites. at first, I began to worry about infringement and have never been made public. However, there are too many people to ask. here is an example-how to capture the "Shenzhen Window" news for your reference only. Do not violate regulations. Thank you.

    Capture the "Tech News" detailed content code page (readNewsDetail. php ):
    CTOHome.com technology news channel
    /*
    * 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 (" Echo" ";
    For ($ I = 4; $ I <6; $ I ++ ){
    Echo" }
    Echo" ";
    }
    ?>
    The crawling method depends on the original code. in advance, you must carefully analyze the HTML original code of the page you want to crawl, find out the rules, and finally write the code. IE has a strong error correction function for HTML syntax. Therefore, as long as the result is displayed correctly, it does not matter if the captured code has some syntax errors.

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.