自动填充并从PHP中的其他页面检索数据

时间:2016-12-05 21:36:51

标签: javascript php curl phantomjs

我在PHP中遇到问题,请求:

  • 运行我的php文件,它移动到" https://whoer.net/checkwhois"
  • 它会自动填写" IP地址或主机名"是文本" 8.8.8.8"并自动按下"检查"
  • 保存整个结果检查

我该怎么做?

1 个答案:

答案 0 :(得分:1)

你可以从linux shell

尝试这个CURL
curl 'https://whoer.net/checkwhois' -H 'origin: https://whoer.net' -H 'x-requested-with: XMLHttpRequest' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'referer: https://whoer.net/checkwhois' -H 'authority: whoer.net' --data 'partial=1&host=8.8.8.8' --compressed

在php中,以下代码应该有效:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://whoer.net/checkwhois');
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch,CURLOPT_POSTFIELDS,  'partial=1&host=8.8.8.8');

$result = curl_exec($ch);

//close connection
curl_close($ch);

echo $result;
相关问题