我正在尝试解析一个页面,我首先要使用用户名和密码登录该网站。所以我开始使用php cURL脚本通过使用GET方法登录页面,但问题是我每次都收到超时错误,但是我设置的超时时间很长。
登录页面:http://myaccount.comeconnect.com/jsp/Login.jsp
包含有效,用户和传递值。
现在,当我在浏览器中使用此URL时,我很容易登录。所以我很困惑为什么我会遇到超时错误。
PHP代码不在同一台服务器上。
PHP代码:
<德尔>//create array of data to be posted $post_data['loginMode'] = '2'; $post_data['username'] = $_GET['user']; $post_data['password'] = $_GET['pass']; $post_data['QuickNavigation'] = "Disabled"; //traverse array and prepare data for posting (key1=value1) foreach ( $post_data as $key => $value) { $post_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $post_string = implode ('&', $post_items);德尔>
$user = $_GET['user'];
$pass = $_GET['pass'];
//create array of data to be posted
$post_data = array( 'loginMode' => '2',
'username' => $user,
'password' => $pass,
'QuickNavigation' => "Disabled");
//create the final string to be posted using implode()
$post_string = http_build_query($post_data, '', '&');
//Params for cURL
$ckfile = './cookie.txt';
$url = 'http://myaccount.comeconnect.com/servlet/MyAccountLogin?'.$post_string;
$timeout=10;
$userAgent= "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1";
//create cURL connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT,$timeout);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
$result = curl_exec($ch);
print_r(curl_getinfo($ch));
echo curl_errno($ch) . '-' .curl_error($ch);
curl_close($ch);
echo $result;
答案 0 :(得分:0)
主机myaccount.comeconnect.com
似乎阻止了与非客户的连接。你最有可能收到错误,因为你没有允许连接的IP地址,不幸的是,没有办法解决这个问题。