Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private void BtnAramaYap_Click(object sender, EventArgs e)
{
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load("https://www.google.com.tr/search?q=" + tbKelime.Text);
var links = doc.DocumentNode.SelectNodes("//h3[@class='r']/a").ToList();
foreach (var link in links)
{
if (link.OuterHtml.Contains("/url?q="))
{
tbBasliklar.Text += System.Web.HttpUtility.HtmlDecode(link.InnerText) + "\r\n";
string hrefValue = link.GetAttributeValue("href", string.Empty);
int index = hrefValue.IndexOf("&");
if (index > 0)
{
var l = hrefValue.Substring(0, index);
tbSiteler.Text += System.Web.HttpUtility.UrlDecode(l.Replace("/url?q=", "")) + "\r\n";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.