dongyi8383 2013-07-07 19:52
浏览 47
已采纳

当Web主机DNS服务器仅返回IP时,PHP通过主机验证百度搜索引擎

I've tried the following on IP addresses with user agents claiming to be the Baidu search engine. Unfortunately Just Host's DNS servers refuse to return anything but the IP address for the host.

<?php
echo 'host: '.gethostbyaddr('180.76.5.168');
echo '<br />'.shell_exec('host -W 2 180.76.5.168');
echo '<br />'.shell_exec('nslookup 180.76.5.168');
?>

Any suggestions for how to get a hold of the host name for Baidu? I've thought about trying to reference specific DNS servers if possible though I'm not sure how to do that with PHP.


Quoted output of my localhost result...

host: baiduspider-180-76-5-168.crawl.baidu.com

Server: Wireless_Broadband_Router.home Address: 192.168.1.1 Name: baiduspider-180-76-5-168.crawl.baidu.com Address: 180.76.5.168

  • 写回答

1条回答 默认 最新

  • doucitao2944 2013-07-10 05:21
    关注

    I was able to use a different DNS server via the host command via shell...

    $p = trim(trim(explode(' pointer',shell_exec('host -W 2 180.76.5.168  68.238.96.12'))[1]),'.');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置