資源簡介
C#調用谷歌英文翻譯,通過HTTP get方式訪問谷歌翻譯網址,抓取翻譯結果

代碼片段和文件信息
using?System;
using?System.Collections;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Text.Regularexpressions;
namespace?ClawCommon
{
????public?static?class?CommonCode
????{
????????///?
????????///?utf-8編碼
????????///?
????????///?
????????///?
????????public?static?string?Utf8Encode(string?str)
????????{
????????????StringBuilder?sb?=?new?StringBuilder();
????????????byte[]?byStr?=?System.Text.Encoding.UTF8.GetBytes(str);?//默認是System.Text.Encoding.Default.GetBytes(str)
????????????for?(int?i?=?0;?i?????????????{
????????????????sb.Append(@“%“?+?Convert.ToString(byStr[i]?16));
????????????}
????????????return?(sb.ToString().ToUpper());
????????}
????????///?
????????///?utf-8解碼
????????///?
????????///?
????????///?
????????public?static?string?Utf8Decode(string?str)
????????{
????????????return?HttpUtility.UrlDecode(str);
????????}
????????///?
????????///?GBK編碼
????????///?
????????///?
????????///?
????????public?static?string?GbkEncode(string?str)
????????{
????????????return?UrlEncoder.Encode(str?Encoding.Default);?
????????}
????????///?
????????///?gb2312編碼
????????///?
????????///?
????????///?
????????public?static?string?Gb2312Encode(string?str)
????????{
????????????return?UrlEncoder.Encode(str?Encoding.Default).ToUpper();
????????}
????????///?
????????///?gb2312解碼
????????///?
????????///?
????????///?
????????public?static?string?Gb2312Decode(string?str)
????????{
????????????return?UrlDecoder.UrlDecode(str.ToLower()?Encoding.Default);
????????}
????????///?
????????///?編碼Unicode字符串
????????///?
????????///?
????????///?
????????public?static?string?UnicodeEncode(string?str)
????????{
????????????StringBuilder?strResult?=?new?StringBuilder();
????????????if?(!string.IsNullOrEmpty(str))
????????????{
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????strResult.Append(“\\u“);
????????????????????strResult.Append(((int)str[i]).ToString(“x“));
????????????????}
????????????}
????????????return?strResult.ToString();
????????}
????????///?
????????///?解碼Unicode字符串
????????///?
????????///?
????????///?
????????public?static?string?DecodeUnicode(string?str)
????????{
????????????//最直接的方法Regex.Unescape(str);
????????????StringBuilder?strResult?=?new?StringBuilder();
????????????if?(!string.IsNullOrEmpty(str))
????????????{
????????????????string[]?strlist?=?str.Replace(“\\“?““).Split(‘u‘);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\.vs\
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\.vs\TranslateTest\
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\.vs\TranslateTest\v14\
?????文件???????68096??2019-05-31?10:31??谷歌翻譯\.vs\TranslateTest\v14\.suo
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\ClawCommon\
?????文件????????3650??2014-09-18?15:44??谷歌翻譯\ClawCommon\ClawCommon.csproj
?????文件????????3802??2014-09-25?13:17??谷歌翻譯\ClawCommon\CommonCode.cs
?????文件???????17952??2014-07-15?15:35??谷歌翻譯\ClawCommon\CommonDate.cs
?????文件???????24494??2014-09-18?16:07??谷歌翻譯\ClawCommon\CommonHtml.cs
?????文件???????32914??2014-10-30?16:41??谷歌翻譯\ClawCommon\CommonHttp.cs
?????文件????????4397??2014-08-11?14:08??谷歌翻譯\ClawCommon\CommonIO.cs
?????文件????????2486??2014-07-15?15:35??谷歌翻譯\ClawCommon\CommonJson.cs
?????文件????????2103??2014-07-15?15:35??谷歌翻譯\ClawCommon\CommonRandom.cs
?????文件?????????503??2014-07-30?15:54??谷歌翻譯\ClawCommon\CommonRegex.cs
?????文件???????17815??2014-09-18?16:02??谷歌翻譯\ClawCommon\Html2Article.cs
?????文件???????24746??2014-07-15?15:35??谷歌翻譯\ClawCommon\HttpHelper.cs
?????文件????????4335??2014-07-15?15:35??谷歌翻譯\ClawCommon\LogHelper.cs
?????文件????????3760??2014-09-11?10:45??谷歌翻譯\ClawCommon\MachineHelper.cs
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\ClawCommon\Properties\
?????文件????????1358??2014-07-15?15:35??谷歌翻譯\ClawCommon\Properties\AssemblyInfo.cs
?????文件????????4227??2014-07-15?15:35??谷歌翻譯\ClawCommon\UrlDecoder.cs
?????文件????????4250??2014-07-15?15:35??谷歌翻譯\ClawCommon\UrlEncoder.cs
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\ClawCommon\bin\
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\ClawCommon\bin\Debug\
?????文件???????58880??2019-05-30?10:34??谷歌翻譯\ClawCommon\bin\Debug\ClawCommon.dll
?????文件??????128512??2019-05-30?10:34??谷歌翻譯\ClawCommon\bin\Debug\ClawCommon.pdb
?????文件??????429056??2013-08-26?16:37??谷歌翻譯\ClawCommon\bin\Debug\Newtonsoft.Json.dll
?????目錄???????????0??2019-05-30?10:33??谷歌翻譯\ClawCommon\bin\Release\
?????文件???????56320??2014-10-24?13:23??谷歌翻譯\ClawCommon\bin\Release\ClawCommon.dll
?????文件??????112128??2014-10-24?13:23??谷歌翻譯\ClawCommon\bin\Release\ClawCommon.pdb
............此處省略59個文件信息
評論
共有 條評論