📄 google.cs
字号:
using System;
using System.Collections;
using SECompare.Config;
using SECompare.Structure;
namespace SECompare.SearchAPI
{
/// <summary>
/// Summary description for Google.
/// </summary>
public class Google
{
public Google()
{
//
// 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)
{
//If start>1000
if(start>1000)
return false;
ArrayList results = GoogleParser.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++)
{
GoogleParser.Parser.Record record = (GoogleParser.Parser.Record)results[i];
QueryRecord r = new QueryRecord(words,EngineSet.Google,(start+i).ToString(),
record.Title,record.URL,record.Snippet);
r.Save();
}
//Write Log file
Config.Log.Append("Google Saved:" + words + "[" + start.ToString() + "-" + (start + results.Count - 1).ToString() + "]");
return true;
}
public static QueryRecord[] Parse(String html,String words,int start)
{
ArrayList results = GoogleParser.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++)
{
GoogleParser.Parser.Record record = (GoogleParser.Parser.Record)results[i];
ret[i] = new QueryRecord(words,EngineSet.Google,(start+i).ToString(),
record.Title,record.URL,record.Snippet);
}
return ret;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -