我正在尝试自动登录到https://www.myicomfort.com/以检索数据。尝试了一些发布的示例,但似乎不起作用。也许我在传递用户名和密码时没有使用正确的字段名称。有人可以帮忙吗?还在学习PHP。谢谢!
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.myicomfort.com/");
curl_setopt($ch, CURLOPT_COOKIEFILE,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$post_array = array(
'ctl00$RightContent$txtUserName'=>'xxxname',
'ctl00$RightContent$txtPwd'=>'xxxpassword',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$output = curl_exec($ch);
curl_close($ch);
`