3

我正在尝试将我们的页面链接到另一个页面,但它位于免责声明警告的另一侧。在每个人都试图做一些不道德的事情之前,我只是想让链接更容易让我的用户访问一个页面 - 我不会抓取任何信息或做一些阴暗的事情!

我遇到问题的链接是: 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);

当我运行脚本时,我会返回原始页面(不是按钮链接到的页面。)任何帮助将不胜感激!

4

1 回答 1

3

Take a look at the form tag:

<form action="answer_disclaimap.asp" method="post" id="Form1">

You use wrong URL to disclaimap.asp. Change it to answer_disclaimap.asp:

$url = 'https://www.bcpao.us/asp/answer_disclaimap.asp';

And use http_build_query():

$data['Answer'] = "Accept";
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($data) );
于 2013-05-13T12:02:21.190 回答