如何使用curl到asp登录

时间:2019-05-20 01:01:07

标签: php codeigniter curl

我无法使用curl通过该网站http://www.jobstreet.com.ph/en/cms/employer/登录 总是说“抱歉,无法访问页面...”

//帐户的用户名和密码         $ username =“ myusername”;         $ password =“ mypassword”;

    //set the directory for the cookie using defined document root var
    //build a unique path with every request to store. the info per user with custom func. I used this function to build unique paths based on member ID, that was for my use case. It can be a regular dir.
    //$path = build_unique_path($path); // this was for my use case

    //login form action url
    $url="http://www.jobstreet.com.ph/en/cms/employer/"; 
    $postinfo = "loginID=".$username."&password=".$password;

    $cookie_file_path ="account.txt";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_NOBODY, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
    //set the cookie the site has for certain features, this is optional
    curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
    curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
       curl_exec($ch);

    //page with the content I want to grab/  protected area 
    curl_setopt($ch, CURLOPT_URL, "https://siva-ph.jobstreet.com//welcome/welcome.asp");
    //do stuff with the info with DomDocument() etc
    $html = curl_exec($ch);
       curl_close($ch);

0 个答案:

没有答案