Master please come in, curl simulation landing problem
I want to do a mock landing, but the general site has a form submitted can be simulated landing success
Are other sites, such as fast selling (https://login.aliexpress.com/)
That's what my code says.
function Vlogin ($url, $request) {
$cookie _jar = Tempnam ('./tmp ', ' cookie ');//temporary file that generates a random file name in the current directory
$ch = Curl_init (); Initializing the Curl module
curl_setopt ($ch, Curlopt_url, $url);//Login page address
curl_setopt ($ch, Curlopt_post, 1);//post mode submission
curl_setopt ($ch, Curlopt_postfields, $request);//content to be submitted
Save the cookie information returned to $cookie_jar in the $cookie_jar file
curl_setopt ($ch, Curlopt_cookiejar, $cookie _jar);
Sets whether the returned data is automatically displayed
curl_setopt ($ch, Curlopt_returntransfer, 1);
Set whether to display header information
curl_setopt ($ch, Curlopt_header, false);
Set whether to output page content
curl_setopt ($ch, Curlopt_nobody, false);
Curl_exec ($ch);
Curl_close ($ch); Get data after Login
return $cookie _jar;
}
Access to the page content via cookies after successful login
function Get_content_by_cookie ($url, $cookie _jar) {
$ch 2 = Curl_init ();
curl_setopt ($ch 2, Curlopt_url, $url);
curl_setopt ($ch 2, Curlopt_header, false);
curl_setopt ($ch 2, Curlopt_returntransfer, 1);
curl_setopt ($ch 2, Curlopt_cookiefile, $cookie _jar);
ers =curl_exec ($ch 2);
Curl_close ($ch 2);
return ers;
}
function Clear_cookie ($cookie _tmp_name) {
@unlink ($cookie _tmp_name);
}
$list _url= ' http://cn.ae.alibaba.com/index.htm ';
$login _url= ' https://login.aliexpress.com/';
$post _data= ' pd=aliexpress&xloginpassport=******&xloginpassword=****** ';
$cookie _file=vlogin ($login _url, $post _data);
$tmp _curl=get_content_by_cookie ($list _url, $cookie _file);
echo $cookie _file;
echo $tmp _curl;
Clear_cookie ($cookie _file);
?>
However, the landing is not successful, the feeling should be $login _url wrong, the quick sell through the form is not submitted, I JS Foundation is not very good, do not understand his code, high-portable point under!
Thanks, man!
------Solution--------------------
You can change your vlogin function to see the return head +body
function Vlogin ($url, $request) {
$cookie _jar = Tempnam ('./tmp ', ' cookie ');//temporary file that generates a random file name in the current directory