For the cur collection terminal, the other party sets the source page-php Tutorial

Source: Internet
Author: User
For information about the cur collection, the recipient sets the source page. This post was last edited by u013569173 at 2015-03-0322: 35: 09 Request & nbsp; URL: miaoo. sinaapp. comcai. phpRequest & nbsp; Method: GETStatus & nbsp; Code: 200 & nb

This post was last edited by u013569173 at 22:35:09 on


Request URL:http://miaoo.sinaapp.com/cai.php
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:saeut=27.156.92.178.1425388310638157
Host:miaoo.sinaapp.com
If-Modified-Since:Tue, 03 Mar 2015 04:57:57 GMT
Referer:http://52jifenbao.com/cai/
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Response Headersview source
Connection:keep-alive
Content-Disposition:inline; filename=download.png
Content-Encoding:gzip
Content-Type:image/png
Date:Tue, 03 Mar 2015 14:31:09 GMT
Last-Modified:Tue, 03 Mar 2015 04:57:57 GMT
Server:nginx/1.4.4
Transfer-Encoding:chunked
Vary:Accept-Encoding
Via:10.67.15.22
X-Powered-By:PHP/5.3.29

To collect is this web site "http://miaoo.sinaapp.com/cai.php", if successful display is a picture, a bit similar to the verification code picture that, the other party should set the judgment source page, no cookie and post data, the source page is Referer: http://52jifenbao.com/cai/. please check the sample code to collect the first information file copied by the 360browser.
------ Solution ----------------------
Common functions must be stored as functions or classes for emergency purposes.
Instead of hitting the gun
include 'curl/curl_get.php';
$url = 'http://miaoo.sinaapp.com/cai.php';
echo curl_get($url);

Curl/curl_get.php
 Function curl_get ($ durl, $ data = array ()){
$ Cookiejar = realpath('cookie.txt ');
$ T = parse_url ($ durl );
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ durl );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 5 );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, 0 );
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ _ SERVER ['http _ USER_AGENT ']);
Curl_setopt ($ ch, CURLOPT_REFERER, "http: // $ t [host]/");
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookiejar );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookiejar );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_ENCODING, 1); // gzip decoding
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true );
If ($ data ){
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
}
$ R = curl_exec ($ ch );
Curl_close ($ ch );
Return $ r;
}

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.