Anonymous user
Yahoo! search interface: Difference between revisions
replaced google -> yahoo
No edit summary |
(replaced google -> yahoo) |
||
Line 15:
using System.Collections.Generic;
using System.Linq;
class
private string query;
private string content;
private int page = 1;
public
this.query = query;
this.content = new WebClient().DownloadString("http://www.test.com/search?q=" + query);
}
public
this.query = query;
this.page = page;
this.content = new WebClient().DownloadString(String.Format("http://www.test.com/search?q={0}&start={1}", query, (this.page - 1) * 10));
}
public int Page {
get {
Line 37:
}
}
public int Length {
get {
Line 44:
}
}
public
get {
ArrayList results = new ArrayList();
foreach (Match e in new Regex("<li class=g><h3 class=r><a href=\"(.+?)\".+?>(.+?)</a></h3><div class=\"s\">(.+?)<cite>").Matches(this.content)) {
string rurl = e.Groups[1].Value;
string rtitle = e.Groups[2].Value.
Replace("<em>", "").Replace("</em>", "").Replace(" <b>...</b>","");
string rcontent = e.Groups[3].Value.
Replace("<em>", "").Replace("</em>", "").Replace(" <b>...</b>", "");
Console.WriteLine(rurl);
results.Add(new
}
return (
}
}
public GoogleSearch NextPage() {
return new
}
public GoogleSearch GetPage(int page) {
return new
}
}
class
public string URL { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public
this.URL = url;
this.Title = title;
|