PHP uses curl to obtain the verification code (sending a cookie for secondary capture ). The powerful curl function in php may not be available yet. next I will introduce an instance used in the work to obtain the verification code using curl and create a cookie. the code below copies the powerful curl function in php, which may not be available to anyone. next I will introduce an instance used in the work to obtain the verification code using curl and create a cookie.
The code is as follows: |
|
$ CookieFile = tempnam ("./tmep", "beast "); If (isset ($ _ GET ["img"]) { $ Url = 'http: // www. bKjia. c0m/phper/php.htm'; // verification code $ Ch = curl_init ($ url ); Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ CookieFile); // Save the returned cookie information to the file Curl_exec ($ ch ); Curl_close ($ ch ); Exit (); } If (isset ($ _ POST ['D']) { $ B = $ _ POST [d]; // verification code $ P = "waybillNo = 1721269381 & inputcode =". $ B; $ Ch = curl_init (); // 2. set options, including URL Curl_setopt ($ ch, CURLOPT_URL, "http://www.bKjia. c0m "); Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ CookieFile ); Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ CookieFile); // send Cookie at the same time Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); Curl_setopt ($ ch, CURLOPT_POST, 1 ); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ p); // submit the query information. $ S = curl_exec ($ ch ); Curl_close ($ ch ); $ Ch = curl_init (); Curl_setopt ($ ch, CURLOPT_URL, http://www.bKjia. c0m ); Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ CookieFile); // send Cookie at the same time Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ CookieFile ); Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); Curl_setopt ($ ch, CURLOPT_POST, 1 ); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ p); // submit the query information. $ Bs = curl_exec ($ ch ); Echo $ bs; // output result Curl_close ($ ch ); } Else { ?>
?> |
Pipeline. the code is as follows...