注冊個百度apikey
php?title=%E
然後代碼如下只看紅色部分就可以了:
using System;
using System
using System
using System
using System
using System
using System
using System
namespace Fangyi
{
public partial class _Default : System
{
protected void Page_Load(object sender
{
GSEntities db = new GSEntities();
for (int i =
{
try
{
System
GetUrl(""
}
catch (Exception ex)
{
System
}
}
db
}
private void GetUrl(string url
{
content cc = new content();
string apikey = "WqLOfG
var enstr = GetHtml
var title = Regex
enstr = Regex
enstr = ReHtml(enstr);
enstr = Regex
")
var atitle = GetHtml
+ apikey + "&q=" + title + "&from=auto&to=auto"
JavaScriptSerializer jss
var aa
title = aa
enstr = enstr
string val = "tt";
if (enstr
{
int i =
var list = enstr
list
{
var a = GetHtml
+ apikey + "&q=" + c + "&from=auto&to=auto"
JavaScriptSerializer jss = new JavaScriptSerializer();
var aa = jss
val += aa
++i;
if (i %
{
System
val += "ntt";
}
System
});
cc
cc
db
db
}
}
public string ReHtml(string HTML)
{
string pattern = @"<[sS]*?>";
Regex regex = new Regex(pattern);
HTML = regex
return HTML;
}
//中文轉為UNICODE字符 forget never
public string ctu(string str)
{
string outStr = "";
if (!string
{
for (int i =
{
//將中文字符轉為
outStr += "u" + ((int)str[i])
}
}
return outStr;
}
//UNICODE字符轉為中文
public string utc(string str)
{
string outStr = "";
if (!string
{
string[] strlist = str
try
{
for (int i =
{
//將unicode字符轉為
outStr += (char)int
}
}
catch (FormatException ex)
{
outStr = ex
}
}
return outStr;
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/14160.html