Can help write a single page of the PHP collection program, and attach an example, how to solve

Source: Internet
Author: User
Can you help to write a single page of the PHP collection program, and attach an example
For example, I want to collect this page: http://news.163.com/12/0613/20/83TJ7PA700014JB6.html

Requirements:
Collect title
Collect text

Thank you!

------Solution--------------------
First go to http://simplehtmldom.sourceforge.net/index.htm (click Download latest Version Form sourceforge.) To download a Simple_html_ dom.php, fool-style regular, another official online has a detailed tutorial, it is easy to read.

PHP code
header ("content-type:text/html; charset=gb2312 "); require dirname (__file__). '/simple_html_dom.php '; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' http://news.163.com/12/0613/20/ 83tj7pa700014jb6.html '); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_useragent, ' Mozilla/ 5.0 (Windows; U Windows NT 6.1; En-us; rv:1.9.1.2) gecko/20090729 firefox/3.5.2 GTB5 '), $htmls = Curl_exec ($ch); Curl_close ($ch); $html = str_get_html ($HTMLS); foreach ($html->find (' #h1title ') as $title) {echo strip_tags ($title). ' 
';//title}foreach ($html->find (' #endText ') as $content) {echo strip_tags ($content);//body}
------ Solution--------------------
PHP to get a list of QQ mailbox friends:
------Solution--------------------
Use crawl page, the title is between the title tag, Body is between body, use regular to remove some unwanted content
  • 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.