获取谷歌搜索结果在c#
问题描述:
我想获得谷歌搜索结果使用HTML敏捷包,但我没有得到正确的页面。我得到的网页是谷歌的主页,获取谷歌搜索结果在c#
(如果你尝试将其粘贴到一个正常的浏览器,它会变成下面的网址)
private void GotoGoogleButton(object sender, EventArgs e)
{
webBrowser1.Navigate(new Uri("https://www.google.com"));
}
private void getResultsButton(object sender, EventArgs e)
{
url = webBrowser1.Url.ToString();
start_parsing(url);
}
public void start_parsing(string URL_)
{
//This function is used to Parse Html source using Html Agility Pack into nodes, and take the important ones (mainly : a,form,iframe)
HtmlAgilityPack.HtmlDocument document = webGet.Load(URL_);
var metaTags = document.DocumentNode.SelectNodes("//a");
// ...
// Continue with parsing...
}
我如何获得的搜索结果,而不是主页?
答
只需将#
替换为search?
即可。但为什么你不能使用google search api这个
+0
我替换它们#并搜索?但他们不是唯一的区别2链接 – dimazaid
+0
@Chamika Sandamal Works很棒,谢谢 –
您必须格式化你的代码(在您的文章,并在你的编辑)。否则,人们无法阅读。 –