获取URL的目标 [英] Get URL's target

查看:182
本文介绍了获取URL的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,

我正在尝试编写可解析此url的C#代码 http://tnstage.dns.microsoft.com/zh-cn/library/cc288672.aspx .

我可以通过使用WebBrowser.Navigate()在Window Forms应用程序中执行此操作,并捕获下面的代码中的navigationdEvent.

Hey guys,

I am trying to write C# code that can resolve this url http://tnstage.dns.microsoft.com/zh-cn/library/d37c20f5-ad09-4a2a-b604-9de665554aac into its target. My terminology may be incorrect, perhapse resolve and target are the wrong words. If you click the above link you end up at http://tnstage.dns.microsoft.com/zh-cn/library/cc288672.aspx.

I am able to do this in a Window Forms application by using WebBrowser.Navigate() and catching the navigatedEvent as in the code below.

<身体>
公共Form1()
{
InitializeComponent();
webBrowser1.Navigated + =新的WebBrowserNavigatedEventHandler(webBrowser1_Navigated);
webBrowser1.Navigate("http://tnstage.dns.microsoft.com/zh-cn/library/d37c20f5-ad09-4a2a-b604-9de665554aac");
}
voidwebBrowser1_Navigated(object sender,WebBrowserNavigatedEventArgs e)
{
//从e获取目标网址
}
public Form1()  
{  
    InitializeComponent();  
    webBrowser1.Navigated += new WebBrowserNavigatedEventHandler(webBrowser1_Navigated);  
    webBrowser1.Navigate("http://tnstage.dns.microsoft.com/zh-cn/library/d37c20f5-ad09-4a2a-b604-9de665554aac");  
}  
 
void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)  
{  
   //Get target url from e  

推荐答案

添加对System.Windows.Forms的引用(右键单击解决方案,然后单击添加->参考),然后只需使用所需的组件即可:

add a reference to System.Windows.Forms (right click on the solution and click add->reference) and simply use the component you need:

<身体>
System.Windows.Forms.WebBrowser
System.Windows.Forms.WebBrowser 


这篇关于获取URL的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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