我正在尝试将我们的页面链接到另一个页面,但它是免责声明警告的另一面。在每个人都试图做一些不道德的事情之前,我只是想让我的用户轻松链接到一个页面 - 我不是在抓任何信息或以其他方式做一些阴暗的事情!
我遇到问题的链接是这样的:
https://www.bcpao.us/asp/disclaimap.asp
我想按下这个按钮:
<input type="submit" name="Answer" value="Accept"\>
这是我的php / curl代码:
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$url = 'https://www.bcpao.us/asp/disclaimap.asp';
$ckfile = tempnam ("d:/temp", "CURLCOOKIE");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data['Answer'] = "Accept";
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// I have tried the following also:
// curl_setopt($ch, CURLOPT_POSTFIELDS, "Submit=Answer%Accept");
$output=@curl_exec($ch);
$info = @curl_getinfo($ch);
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo "output is:'" . $output . "'";
echo "<br>";
echo "info is:";
print_r($info);
当我运行脚本时,我会返回原始页面(而不是按钮链接到的页面。)任何帮助都将非常感谢!
答案 0 :(得分:3)
查看form
代码:
<form action="answer_disclaimap.asp" method="post" id="Form1">
您使用错误的URL
与disclaimap.asp
。将其更改为answer_disclaimap.asp
:
$url = 'https://www.bcpao.us/asp/answer_disclaimap.asp';
$data['Answer'] = "Accept";
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($data) );