抓取服务器主机信息,curl怎样获取指定IP主机的信息

使用CDN后,网站域名对应的是N台CDN主题,例如新浪网,通过 NSLOOKUP 就可以看出,它指向了多个IP。

Z:\>nslookup www.sina.com.cn

Server: c.center-dns.jsinfo.net

Address: 61.177.7.1

Name: newsnj.sina.com.cn

Addresses: 202.102.75.169, 202.102.75.170, 202.102.75.161, 202.102.75.162 202.102.75.163, 202.102.75.164, 202.102.75.165, 202.102.75.166, 202.10 2.75.167 202.102.75.168

Aliases: www.sina.com.cn, jupiter.sina.com.cn

使用 curl -I http://www.sina.com.cn/ 可以得到 HTTP 头信息,

但是curl获取的主机是从DNS服务器随机取到的,

怎么样才能查看指定IP上的HTTP信息呢?

使用IP访问,并使用 -H 参数添加 HTTP 头“Host:www.sina.com.cn”,就可以了!

D:\>curl -I http://www.sina.com.cn/

HTTP/1.1 200 OK

Via: 1.0 nanjing75-162.HP08040106.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW

Connection: Keep-Alive

Proxy-Connection: Keep-Alive

Content-Length: 390160

Expires: Fri, 26 Sep 2008 05:22:11 GMT

Date: Fri, 26 Sep 2008 05:21:11 GMT

Content-Type: text/html

ETag: "5c2d7-457c5a8340d40"

Server: Apache

Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT

Accept-Ranges: bytes

X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix

Cache-Control: max-age=60

Vary: Accept-Encoding

X-Cache: HIT from nanjing75-162.HP08040106.sina.com.cn

从 DNS 解析到 202.102.75.162 主机

D:\>curl -I -H "Host:www.sina.com.cn" http://202.102.75.169/

HTTP/1.1 200 OK

Via: 1.0 nanjing75-169.HP08040113.sina.com.cn:80 (squid/2.6.STABLE13), 1.0 TRFW

Connection: Keep-Alive

Proxy-Connection: Keep-Alive

Content-Length: 390160

Age: 3

Expires: Fri, 26 Sep 2008 05:21:07 GMT

Date: Fri, 26 Sep 2008 05:20:07 GMT

Content-Type: text/html

ETag: "5c2d7-457c5a8340d40"

Server: Apache

Last-Modified: Fri, 26 Sep 2008 05:19:09 GMT

Accept-Ranges: bytes

X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix

Cache-Control: max-age=60

Vary: Accept-Encoding

X-Cache: HIT from nanjing75-169.HP08040113.sina.com.cn

CURL通过设定 -H 参数添加 HTTP 头“Host:www.sina.com.cn”,就可以了实现获取指定IP主机的信息。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值