PHP Collection csdn Blog Sidebar reading ranking

Source: Internet
Author: User
Tags getting started with php

In the project to use the collected data, so first take CSDN blog to try. This library uses the simple HTML DOM (official website), which makes it easy to traverse HTML documents.  

<?PHPinclude_once(' simple_html_dom.php '); Header(' Content-type:text/html;charset=utf-8 '); $html= file_get_html (' http://blog.csdn.net/szy361 '); $res=$html->find (' #hotarticls ul.panel_body li A[title] ');//get the title of a under the UL tag Class Panel_bodya under Id=hotarticls    $span=$html->find (' #hotarticls ul.panel_body li span ');//get span    foreach($res  as $element){        $arr[] =$element->title. ' + '.$element->href;//Connect the title value and the value of the href through + .    }    foreach($span  as $e){        $BRR[] =$e->innertext;//get an array of values under span    }        //make two arrays into a new two-dimensional array     for($i= 0;$i<Count($res);$i++){        $CRR[] =Explode(' + ',$arr[$i]); $CRR[$i][] =$BRR[$i]; }    return $CRR;

Extended:

Getting started with PHP simple HTML DOM Parser

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.