程序从浏览器获取地址并查找IP地址 [英] program to take address from browser and finding the ip address

查看:169
本文介绍了程序从浏览器获取地址并查找IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个从浏览器获取地址的代码(仅限高举一个Ex:www.google.com而不是www.google.com?id-712hh2hadsadasdsduh2)并通过对地址执行任何操作来查找其IP。请帮助我....请感谢给我回复的人..请...

解决方案

我不知道为什么你需要从浏览器获取地址(不确定这是你真正需要的),但你要问的一切都很简单。



解析URL以删除查询参数:http://msdn.microsoft.com/en-us/library/system.uri%28v = vs.110%29.aspx [ ^ ]。



只需创建 System.Uri 使用带有as参数的构造函数,并使用这些属性来读取你的URI部分ed。



对于ping,请使用该课程,不要太惊讶, System.Net.NetworkInformation.Ping

http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx [ ^ ]。







要通过URI查找IP,您需要充当DNS的客户端: http://en.wikipedia.org/wiki/DNS [ ^ ]。



这是如何: http://msdn.microsoft.com/en-us/library/system。 net.dns%28v = vs.110%29.aspx [ ^ ]。



-SA


您遇到了问题。你不能只ping任何你想要的网址。许多曾经响应ping的网站因为针对它们的攻击而不再做了。



您可以尝试ping网站,但结果不可信任。我无法让你知道该网站是否真的使用ping进行响应。



除此之外,网络服务器不响应ping。 Web服务器上的网络堆栈和ICMP ping消息只能到达网络堆栈的第3层。它永远不会让它更高(对Web服务器)所以你不可能知道web服务器是否响应。



那么,有什么用的信息??

I need a code that takes address from browser (only highlited one Ex:www.google.com instead of www.google.com?id-712hh2hadsadasdsduh2) and find its ip by performing any operation on address.please help me please....please I will be thankful to one who send me reply..please.please

解决方案

I have no idea why would you need to get address from browser (not sure this is what you really need), but everything you are asking about is easy.

Parsing URL to remove query parameters: http://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx[^].

Just create the instance of System.Uri using the constructor with as string parameter, and use the properties to read the parts of URI you need.

And for pinging, use the class, not to much of surprise, System.Net.NetworkInformation.Ping:
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx[^].

[EDIT]

To find IP by URI, you need to act as a client of DNS: http://en.wikipedia.org/wiki/DNS[^].

This is how: http://msdn.microsoft.com/en-us/library/system.net.dns%28v=vs.110%29.aspx[^].

—SA


You have a problem. You cannot just ping any web address you want. A lot of sites that used to respond to ping no longer do because of attacks that have been launched against them.

You can try to ping a site, but the result cannot be trusted. There i no way for you to know if the site is actually responding using ping.

On top of that, web servers do not respond to pings. The network stack on the web server does and ICMP ping messages only go up to Layer 3 of the network stack. It never makes it any higher (to the web server) so you can't possibly know if the web server responding of not.

So, what use is the information??


这篇关于程序从浏览器获取地址并查找IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆