【发布时间】:2013-02-11 05:08:36
【问题描述】:
我正在尝试使用http://nlp.stanford.edu:8080/corenlp/process 的表单以编程方式处理我的声明。我在 PHP/CURL 中有以下代码 sn-p。但是,它不是处理语句,而是返回表单的 HTML - 就好像没有发送 post 参数一样。我检查了我是否发送了所需的参数。有人可以指导我做错了什么吗?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://nlp.stanford.edu:8080/corenlp/process");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/14.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_POST, true);
$data = array(
'outputFormat' => 'xml',
'input' => 'Here is a statement to process',
'Process' => 'Submit Query'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
echo $result;
【问题讨论】:
-
您是否复制了该表单的所有内容? cookie、引用者、反垃圾邮件隐藏字段等...?
-
提交按钮未标注
Submit Query。 -
页面中有一些cookies,请尝试包含它们
-
如何添加cookies、referers等?对不起,我是 CURL/PHP 的新手
-
对于 cookie -
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");对于推荐人curl_setopt($ch, CURLOPT_REFERER, "http://www.example.net");