就是想通过
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=58.60.125.97
这个接口来查询IP地址的信息返回值 是
var remote_ip_info = {"ret":1,"start":"58.60.124.0","end":"58.60.125.255","country":"\u4e2d\u56fd","province":"\u5e7f\u4e1c","city":"\u6df1\u5733","district":"\u5357\u5c71","isp":"\u7535\u4fe1","type":"","desc":""};注意这个里有\u4e2d\u56fd 一看这是没有问题的.如果是直接写HttpUtility.UrlDecode("\u4e2d\u56fd")显示是中文"中国".但悲催的是这里的是程序来输出的.int intStart = strReturn.IndexOf("{") + 1;
int intLength = strReturn.IndexOf("}") - intStart; strReturn = strReturn.Substring(intStart, intLength);
strReturn = strReturn.Replace("\"", "");
strReturn = strReturn.Replace("\\", "$");
string[] arrReturn = strReturn.Split(','); string strCountry = arrReturn[3];
string strProvince = arrReturn[4];
string strCity = arrReturn[5];
string strDistrict = arrReturn[6];
string strISP = arrReturn[7]; return HttpUtility.UrlDecode( strCountry.Replace("$",@"\") + "|" + strProvince + "|" + strCity + "|" + strDistrict + "|" + strISP );在这里无论怎么搞.最后的\u4e2d\u56fd都变成\\u4e2d\\u56fd.于是HttpUtility.UrlDecode输出的仍然是\u4e2d\u56fd.搞了我一晚上了.万恶的微软啊.你为什么要自动加上.你以为\就是一个反斜杠,硬要来个\表示转义.我顶!
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=58.60.125.97
这个接口来查询IP地址的信息返回值 是
var remote_ip_info = {"ret":1,"start":"58.60.124.0","end":"58.60.125.255","country":"\u4e2d\u56fd","province":"\u5e7f\u4e1c","city":"\u6df1\u5733","district":"\u5357\u5c71","isp":"\u7535\u4fe1","type":"","desc":""};注意这个里有\u4e2d\u56fd 一看这是没有问题的.如果是直接写HttpUtility.UrlDecode("\u4e2d\u56fd")显示是中文"中国".但悲催的是这里的是程序来输出的.int intStart = strReturn.IndexOf("{") + 1;
int intLength = strReturn.IndexOf("}") - intStart; strReturn = strReturn.Substring(intStart, intLength);
strReturn = strReturn.Replace("\"", "");
strReturn = strReturn.Replace("\\", "$");
string[] arrReturn = strReturn.Split(','); string strCountry = arrReturn[3];
string strProvince = arrReturn[4];
string strCity = arrReturn[5];
string strDistrict = arrReturn[6];
string strISP = arrReturn[7]; return HttpUtility.UrlDecode( strCountry.Replace("$",@"\") + "|" + strProvince + "|" + strCity + "|" + strDistrict + "|" + strISP );在这里无论怎么搞.最后的\u4e2d\u56fd都变成\\u4e2d\\u56fd.于是HttpUtility.UrlDecode输出的仍然是\u4e2d\u56fd.搞了我一晚上了.万恶的微软啊.你为什么要自动加上.你以为\就是一个反斜杠,硬要来个\表示转义.我顶!
解决方案 »
- word转html 用office组件问题?有时候转不了??
- ASP.NET MVC3 multiple Html.Partial question
- 我的3级下拉菜单,在其他浏览器都可以显示,就是IE6出不来,请高手帮我看看
- 急急急。。。安装好VS2005 SP1为什么还是不能创建WEB文件
- select控件选中问题
- 用Jmail发信怎么收到的内容老是空或者是乱码啊
- 求教一个用asp.net生成绝对不重复订单号的可行方法
- 在C#中哪个函数可以实现从某一字符串中删除指定字符
- ASP中的一个小问题!!!大家指点一下!!!20分
- 请教框架问题,着急!
- 请教一个SQL语句..
- 帮我看一下,这样写对不对?document.getElementById("TextBox1").value = IPData[2];
Regex.Unescape
不知廉耻
string ipAddress = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=58.60.125.97";
WebRequest request = WebRequest.Create(new Uri(ipAddress));
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string responseStr = string.Empty;
responseStr= HttpUtility.HtmlDecode(reader.ReadToEnd());
reader.Dispose();
responseStr = responseStr.Substring(responseStr.IndexOf("=") + 2);
responseStr = responseStr.Substring(0, responseStr.Length - 1);
JavaScriptSerializer jss = new JavaScriptSerializer();
IpInfo ipInfo=jss.Deserialize<IpInfo>(responseStr);
public class IpInfo
{
public string ret { get; set; }
public string start { get; set; }
public string end { get; set; }
public string country { get; set; }
public string province { get; set; }
public string city { get; set; }
public string district { get; set; }
public string isp { get; set; }
public string type { get; set; }
public string desc { get; set; }
}
me too too too too too too too too
me too too
顺便来接下分!!!
me too too too too too too too too too
me too too too too too too too too too too
没错。自己不行,还敢说.net的不好。什么DX?
我也认为.net垃圾,java的理论很完善,java的语法和独特的语言结构充分的体现了理念。.net抄java又不完全理解偷窃Java的理论基础,.net加入了自己的想法,就像有xx特色的社会主义,不伦不类。不过,只要能挣钱,管他是java还是.net,谁能用最少低价解决问题就用谁。如果对技术追求的话,我个人认为java的理论不错,C的效率很好