> >

Re: PHP cURL to achieve simulation login and collection method of use

time:17-06-29 forum:PHP tools and code
  Case analysis
1, simple collection of

the simple collection referred to here refers to a single page GET request collection, it is easy to easily get the result of the page return even through the file_get_contents function.

code fragment of file_get_contents
[code]
$url ='http://demo.zjmainstay.cn/php/curl/simple.html';
$content = file_get_contents ($url);
echo statements; Jmainstay.cn/php/curl/simple.html';
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); / / / / / return data do not directly output
$content = curl_exec. NT; [/code]

two,

that requires parameters, a page request needs to pass some parameters, can be a GET request, or a POST request. The acquisition of this situation can still be realized by using file_get_contents outside some parameters, but we will not show it here.

code fragment cURL GET
this request, we can choose the search engine as a demonstration, for example, I Baidu search a word "PHP cURL", after entering the return, we will get a similar http://www.baidu.com/s? Ie=utf-8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

prev:PHP curl function simulated crawler (ope... next:Advantages and disadvantages of cURL, fi...
post comments
Notice



Approved   People in Shandong have gone through...   The teacher was red for the student'...   Sichuan leg free man wrote thousands...   The domain name stolen and retrieved...   "Silly" old lady Ding Ruiyun: promis...
rand   Using iconv to transform UTF-8 Chine...   The strftime () function converts mo...   PHP string intercepting function   The interrotation of time stamp func...   PHP code for different cities from I...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com