从网站网址列表中提取域名 [英] Extract domain names from a list of web site urls

查看:71
本文介绍了从网站网址列表中提取域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个asp.net控制台应用程序。并且控制台应用程序从外部服务读取网站。但网站有不同的格式,,,这些是格式的样本: -

I am working on an asp.net console application. and the console application reads the websites from an external service. but the websites comes with different formats,,, these are samples of the formats:-

http://www.****.co.uk/ 
http://www.****.com/global/index.htm 
https://www.****.com/
https://****.com/
www.***.net
*******.com


现在我只需从上面提取域名网址(我不需要包含http或https或wwww等)。所以我不确定哪个是最好的appraoch?我需要这个,因为我正在使用名为
的.netlibrary
https ://www.nuget.org/packages/ARSoft.Tools.Net
允许我从网站域名获取电子邮件托管公司..但如果我应用上述网址,我会收到错误,除了最后一个网址,其中只包含我正在寻找的域名
来提取...

所以有人可以就此提出建议吗?

now i need to only extract the domain name from the above urls (i do not need to include http or https or wwww , etc..). so i am not sure which is the best appraoch to do so? i need this as i am using a .netlibrary named https://www.nuget.org/packages/ARSoft.Tools.Net which allow me to get the email hosting company from the website domain name.. but if i apply the above urls i will get errors except for the last url which only include the domain name which i am looking to extract...

so can anyone advice on this please?

谢谢

推荐答案

查看以下内容是否有用。

See if the following is helpful.

https://stackoverflow.com/questions/14211973/get-host-domain-from-url

从上面的链接

string host = Request.Url.Host;

Uri myUri = new Uri("http://www.contoso.com:8080/");   
string host = myUri.Host;  // host is "www.contoso.com"


Uri.GetLeftPart( UriPartial.Authority )


这篇关于从网站网址列表中提取域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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