, curl simulates the issue of landing

Source: Internet
Author: User
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
  • 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.