First, write a simple crawl page function
Copy Code code as follows:
function Getsources ($URL, $User _agent= ', $Referer _url= ')//crawl a specified page
{
$URL page address that needs to be crawled
$User _agent need to return
This article mainly introduces PHP using curl in the detailed analysis of Php curl and common pits, and now share to everyone, but also for everyone to make a reference. Let's take a look at it with a little knitting.
Tanabata, as a
Common usage code examples of cURL library in a wave of PHP, and a wave of curl. Common usage code examples of cURL library in a wave of PHP, a wave of curlphp CURL is a good function, the following are some of the good segment 0, the basic example
A common usage code example of a Curl library in PHP, a wave of curl
PHP Curl is a good feature, a few good pieces of the following collection
0. Basic examplesGeneral Flow:
$to _url=$_get[' url '];p rint_r ($_get), if (substr ($to _url,0,1) = = '/'
Curl collection garbled and not to collect PHP
The PHP program is encoded with gbk2312:
$url = "http://www.sina.com.cn";//gbk2312 encoding
$url = "http://www.163.com";//gbk2312 encoding
$url = "http://www.sohu.com";//gbk2312 encoding
$ch = Curl_
Curl collection garbled and not to collect PHP
The PHP program is encoded with gbk2312:
$url = "http://www.sina.com.cn";//gbk2312 encoding
$url = "http://www.163.com";//gbk2312 encoding
$url = "http://www.sohu.com";//gbk2312 encoding
$ch = Curl_
Curl collection garbled and not to collect PHP
The PHP program is encoded with gbk2312:
$url = "http://www.sina.com.cn";//gbk2312 encoding
$url = "http://www.163.com";//gbk2312 encoding
$url = "http://www.sohu.com";//gbk2312 encoding
$ch = Curl_
This article mainly introduces common code examples of cURL library usage in PHP. cURL in the Unix-like world is built in PHP, which makes Linux and MacOS users very friendly, if you need a friend, you can refer to the php CURL which is a good
As for my problem, the returned value of curl_errno () is 6. based on the above data query, we know that the reason is Couldn 'tresolvehost. thegivenremotehostwasnotresolved. this is the cause of "failed host resolution". now, I know how to solve
PHP Curl is a good feature, the following collection of a few pieces of good clips
0. Basic examplesGeneral Process:
$to _url=$_get[' url '];
Print_r ($_get);
if (substr ($to _url,0,1) = = '/') {
$to _url= "http://www.amazon.com". $to _url;
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.