Skip to content

Instantly share code, notes, and snippets.

@fluupo
Created August 20, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fluupo/10fd42379a89a5cde04dd6c3282795c7 to your computer and use it in GitHub Desktop.
Save fluupo/10fd42379a89a5cde04dd6c3282795c7 to your computer and use it in GitHub Desktop.
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