如何在Web浏览器中读取正在搜索的内容,并将其返回到MessageBox?

时间:2018-06-19 09:54:52

标签: .net vb.net url-redirection traffic

我有一个我正在练习的应用程序,它会将某个网站的流量重定向到另一个网站。

  

例如

1

User opens a web-browser and types in a link like "www.youtube.com".

2

The user presses 'enter' and they're forwarded to www.youtube.com.

现在,如果我不想访问此网站,我想将搜索重定向到其他域名,该怎么办?我该怎么做?它看起来像这样吗?

Dim website As "www.youtube.com"
If website.IsSearched = True Then
MesssageBox.Show("This site is whitelisted.")

我知道这段代码会 NOT 工作,但是,这是我想要实现的一个简短示例。

对项目的任何帮助或参考都会很棒。

2 个答案:

答案 0 :(得分:0)

want to redirect the search to a different domain

You could use the hosts file, which can override dns and make browsers believe youtube.com's IP address is whatever you like. You could maybe redirect it to 127.0.0.1 where you handle the incoming request yourself, like a proxy, and give the edited response back. Https obviously won't work, since you are not really youtube.com, but http will.

tldr; this is not a .net question

答案 1 :(得分:0)

在网络浏览器导航事件中执行此操作。 当用户按下Enter键时,导航将触发,然后您可以检查网址并执行任何操作。