uzun araştırmalarım sonucu aşağıdaki kodları buldum hata almadan çalıştırdım fakat kaçınca sırada olduğumun çıktısını alamadım yardım ederseniz birlikte bulsak çok sevinirim.
private void btnSubmit_Click_Click(object sender, EventArgs e)
{
string strUrl = txtUrl.Text;
Uri newUri = new Uri("http://www.yahoo.com");
int I = GetPosition(newUri, txtKeyword.Text);
}
public static int GetPosition(Uri url, string searchTerm)
{
string raw = "http://www.google.com.tr/search?num=39&q={0}&btnG=Search";
string search = string.Format(raw, HttpUtility.UrlEncode(searchTerm));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(search);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
{
string html = reader.ReadToEnd();
return FindPosition(html, url);
}
}
}
private static int FindPosition(string html, Uri url)
{
//string lookup = "(<a href=\")(\\w+[a-zA-Z0-9.-?=/]*)\" class=l";
string lookup = "(<h3 class=\"r\"><a href=\")(\\w+[a-zA-Z0-9.\\-?=/]*)";
MatchCollection matches = Regex.Matches(html, lookup);
for (int i = 0; i < matches.Count; i++)
{
string match = matches[i].Groups[2].Value;
if (match.Contains(url.Host))
return i + 1;
}
return 0;
}