我想通过 cUrl
向this site提交任何IP地址 . 我的cUrl选项无法正常工作:
$h = curl_init();
curl_setopt($h, CURLOPT_URL, "http://www.whatismyip.com/ip-whois-lookup/");
curl_setopt($h, CURLOPT_POST, true);
curl_setopt($h, CURLOPT_POSTFIELDS, array(
'IP' => '2.179.144.117',
'submitted' => 'submitted'
));
curl_setopt($h, CURLOPT_HEADER, false);
curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($h);
echo $result;
2 回答
快速检查发送到该网页的 Headers ,显示“已提交”的帖子变量应设置为true,而不是提交 .
Remark :请注意,whatismyip.com可能不允许通过抓取访问其工具 .
使用
http_build_query()
函数为您的数组数据提供,以便可以在请求的IP上正确解码: