How to crawl other sites ' pages in addition to _php

Source: Internet
Author: User
Keywords Supplement page site how we CH FP
In the actual application, often encounter some special circumstances, such as the need for news, weather forecast, and so on, but as a personal site or the strength of small sites we can not have so much human and material resources to do these things, how to do?
Fortunately, the Internet is a resource-sharing, we can use the program to automatically pull the pages of other sites back after processing by our use.
With what, that comrade-in-arms give is not, in fact, in PHP has this function, that is, with the Curl library. Take a look at the code below!

$ch = Curl_init ("http://dailynews.sina.com.cn");
$fp = fopen ("Php_homepage.txt", "w");

curl_setopt ($ch, Curlopt_file, $fp);
curl_setopt ($ch, Curlopt_header, 0);

Curl_exec ($ch);
Curl_close ($ch);
Fclose ($FP);
?>

But sometimes there are some errors, but they have actually been downloaded! I asked the foreigner, they did not give me an answer, I think really not, just add one in front of the function, so that we just have to $txt the appropriate analysis, we can secretly crawl Sina news! However, it is not necessary for the good! In case of legal disputes, here just want to tell you that PHP function is very powerful! You can do a lot of things!

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"
  • Related Article

    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.