C#根据IP地址获取城市
来源:互联网 发布:讯飞输入法皮肤知乎 编辑:程序博客网 时间:2024/06/12 01:48
protected void Page_Load(object sender, EventArgs e)
{
string ipAddress = Request.UserHostAddress;
string url = "http://www.ip138.com/ips138.asp?ip="+ipAddress+"&action=2";
string pagecode = getPageCode(url, Encoding.GetEncoding("gb2312"));//getPageCode方法获取页面源码
string str = "^.*</li><li>参考数据一:(?<content>.+?)</li></ul>.*$";//正则表达式
Regex rgClass = new Regex(str, RegexOptions.Singleline);
Match match = rgClass.Match(pagecode);
string a = match.Groups["content"].Value;
Response.Write(a);
{
string ipAddress = Request.UserHostAddress;
string url = "http://www.ip138.com/ips138.asp?ip="+ipAddress+"&action=2";
string pagecode = getPageCode(url, Encoding.GetEncoding("gb2312"));//getPageCode方法获取页面源码
string str = "^.*</li><li>参考数据一:(?<content>.+?)</li></ul>.*$";//正则表达式
Regex rgClass = new Regex(str, RegexOptions.Singleline);
Match match = rgClass.Match(pagecode);
string a = match.Groups["content"].Value;
Response.Write(a);
}
getPageCode方法在上一个博客里。
- C#根据IP地址获取城市
- 根据Ip地址获取城市名
- Android 根据IP地址获取城市
- 根据ip获取城市
- 根据ip获取城市
- 根据ip获取城市
- 根据ip地址查询城市
- 根据IP地址定位城市
- 根据IP获取城市名称
- 根据ip获取城市名
- 根据IP获取城市代码
- C#获取外网IP地址;C#获取所在IP城市地址
- 根据IP获取地址
- 根据ip获取地址
- 根据ip获取地址
- 根据IP获取地址
- 根据ip地址获取所在省市城市地区的真实地址/php函数
- PHP获取IP地址及根据IP判断城市实…
- 从“执行”看领度软件和其他企业2.0以及传统OA软件的区别
- 云计算基金
- asmack实现端到端的消息回执(XEP-0184: Message Delivery Receipts)
- 判断二叉查找树的合法性 Validate Binary Search Tree
- Linux帮助命令
- C#根据IP地址获取城市
- PHP 进阶(五)AJAX
- Java用户界面
- 求某年某月某日是该月的第几天
- Linux上mount 挂载windows共享文件权限问题
- xshell颜色配置方案
- ORACLE 中ROWNUM用法总结!
- oracle 11g更改字符集
- spark/shark 部署 (zz)