如何使用提交按钮上没有名称属性的curl提交表单?使用CURL提交表格
例如,目标站点有如下提交按钮:
<input id='some' value='value' type='submit' >
这是我有:
$post_data['name'] = 'xyz';
$post_data['some'] = 'value';
foreach ($post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
$ch = curl_init($web3);
//set options
//curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
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);
//set data to be posted
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($ch);
提交按钮本身不必具有任何名称属性 - 只有字段本身。 – Lix
但是如何提交呢?我编辑了代码..你可以举一个例子 – zista
你必须发送帖子请求到那个你得到页面的响应URL。 – pce