📄 yahoo.cs
字号:
using System;
using System.IO;
using System.Text;
using System.Collections;
using SECompare.Config;
using SECompare.Structure;
namespace SECompare.SearchAPI
{
/// <summary>
/// Summary description for Yahoo.
/// </summary>
public class Yahoo
{
public Yahoo()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Crawl and save results.
/// </summary>
/// <param name="words"></param>
/// <param name="start"></param>
/// <param name="maxResults"></param>
/// <returns></returns>
public static bool Crawl(String words,int start,int maxResults)
{
ArrayList results = YahooParser.Parser.Run(words,start,maxResults);
//If no returns, there is no results.
if(results==null||results.Count==0)
return false;
//If returned results is too little, there are no more results.
if(results.Count<(maxResults*0.9)&&start>10)
return false;
for(int i=0;i<results.Count;i++)
{
YahooParser.Parser.Record record = (YahooParser.Parser.Record)results[i];
QueryRecord r = new QueryRecord(words,EngineSet.Yahoo,(start+i).ToString(),
record.Title,record.URL,record.Snippet);
r.Save();
}
//Write Log file
Log.Append("Yahoo Saved:" + words + "[" + start.ToString() + "-" + (start+results.Count-1).ToString() + "]");
return true;
}
public static QueryRecord[] Parse(String html,String words,int start)
{
ArrayList results = YahooParser.Parser.Run(html);
//If no returns, there is no results.
if(results==null||results.Count==0)
return null;
//Construct return value
QueryRecord[] ret = new QueryRecord[results.Count];
for(int i=0;i<results.Count;i++)
{
YahooParser.Parser.Record record = (YahooParser.Parser.Record)results[i];
ret[i] = new QueryRecord(words,EngineSet.Yahoo,(start+i).ToString(),
record.Title,record.URL,record.Snippet);
}
return ret;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -