What is not found in php information collection? How to solve

Source: Internet
Author: User
What is not found in php information collection? Today, I suddenly wanted to collect something. it was okay at the beginning. everything was normal. but after a while, I couldn't collect anything. I don't know where the problem is. the code is as follows. please ask? Function & nbsp; getContent ($ url) & nbsp ;{& nbsp; & nbsp; what content cannot be found in php information collection?
Today, I suddenly wanted to collect something. it was okay at the beginning. everything was normal. but after a while, I couldn't collect anything. I don't know where the problem is. the code is as follows. please ask?
Function getContent ($ url ){
$ Url = trim ($ url );
$ Content = '';
If (extension_loaded ('curl ')){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array (
'Accept-Language: zh-cn ',
'Connection: Keep-alive ',
'Cache-Control: no-cache'
));
$ User_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 )";
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ user_agent );
$ Content = curl_exec ($ ch );
Curl_close ($ ch );
} Else {
$ Content = file_get_contents ($ url );
}
Return trim ($ content );

} // End func getContent (); PHP Curl information collection simulated browser acquisition shared:
------ Solution --------------------
What is the url you collected?
------ Solution --------------------

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.