3
有誰知道嗎?我通過拼寫檢查「促進劑」,這是一個非常好的詞。我回來「加速」?當我在瀏覽器中打開Google並輸入「accelerants」時,它不會顯示「加速」?Google拼寫檢查程序API
using System;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace SpellCheck
{
class googel_SP
{
public string word;
public void run_G()
{
string retValue = string.Empty;
string Iword = "accelerants";
try
{
string uri = "https://www.google.com/tbproxy/spell?lang=en:";
using (WebClient webclient = new WebClient())
{
string postData = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?> "
+ "<spellrequest textalreadyclipped=\"0\" ignoredups=\"0\" ignoredigits=\"1\" "
+ "ignoreallcaps=\"1\"><text>{0}</text></spellrequest>", Iword);
webclient.Headers.Add("Content-Type", "application/x-www-form- urlencoded");
byte[] bytes = Encoding.ASCII.GetBytes(postData);
byte[] response = webclient.UploadData(uri, "POST", bytes);
string data = Encoding.ASCII.GetString(response);
if (data != string.Empty)
{
retValue = Regex.Replace(data, @"<(.|\n)*?>", string.Empty).Split('\t')[0];
Console.WriteLine(" word in -> " + word + " word out -> " + retValue);
}
}
}
catch (Exception exp)
{
}
//return retValue;
}
}
}