直接获取访问者的当前城市
来源:互联网 发布:越南芽庄网络怎么样 编辑:程序博客网 时间:2024/06/10 13:12
通过Ip地址获取城市,ASP.Net
需要引入Json类
//===========================
public string getCity()
{
string url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js";
string _strResult = getRequestInterface(url);
_strResult = _strResult.Substring(_strResult.IndexOf("=") + 1);
_strResult = _strResult.Substring(0, _strResult.Length - 1);
JObject o = JObject.Parse(_strResult);
_strResult = o["city"].ToString();
return _strResult;
}
public string getRequestInterface(string _strUrl)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(_strUrl);
myRequest.Method = "get";
myRequest.ContentType = "text/xml;charset=gb2312";
string strBuff = String.Empty;
using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
{
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("GB2312"));
strBuff = reader.ReadToEnd();
}
return strBuff;
}
- 直接获取访问者的当前城市
- 获取到访问者的当前所在页面
- 获取可执行文件的当前路径
- 获取应用程序的当前路径
- 获取进程的当前目录
- 获取Repeater的当前行号
- 获取IOS的当前版本号
- 获取FragmentPagerAdapter的当前fragment
- 获取AutoCAD的当前配置文件
- 获取程序的当前路径
- 获取系统的当前信息
- 获取对象的当前状态
- 获取应用的当前版本号
- 获取项目程序集的当前版本
- 获取SQL Server的当前连接数
- java获取用户的当前工作目录
- javascript获取select的当前值
- 获取浏览器的当前页面地址
- Linux shell编程入门
- POI LastRowNum and PhysicalNumberOfRows
- Oralce中的to_date()函数
- FileSystemWatcher之错误处理
- android 简单动画实现
- 直接获取访问者的当前城市
- USACO / Subset Sums集合 (DP)
- 排序
- WinCE开机Logo的实现(USB下载图片到nandflash)
- Building NetCDF* with the Intel® Compilers
- 网络5——传输层
- mysql上课笔记(一)
- Linux内核配置之图形化的配置make xconfig
- Bookmarks_2012_06_13