如何在asp.net中获取网站页面标题

时间:2015-01-07 13:24:52

标签: jquery html asp.net

我想获得网站页面标题。如果我想解释我想要的东西,请阅读。 当你去www.yahoo.com点击一个有这个链接的新闻标题的链接


https://en-maktoob.news.yahoo.com/mahesh-bhatt-bheegh-loon-celebrates-unleashing-womans-sensuality-133609637.html


在----- https://en-maktoob.news.yahoo.com----

之后

我们可以看到页面标题是----

马赫什-巴特-bheegh-洛翁庆祝-肆行-女子-感性-133609637

我的问题是如何在yahoo.com或任何其他网站之后获得页面标题。

请指导我在asp.net 毕竟非常感谢。

1 个答案:

答案 0 :(得分:0)

假设url是一个字符串变量,那么在c#中你需要的是Path.GetFileNameWithoutExtension。见here

e.g。

    string url = "https://en-maktoob.news.yahoo.com/mahesh-bhatt-bheegh-loon-celebrates-unleashing-womans-sensuality-133609637.html";

    Console.WriteLine("{0}",Path.GetFileNameWithoutExtension(url));

输出

 mahesh-bhatt-bheegh-loon-celebrates-unleashing-womans-sensuality-133609637