zoukankan
html css js c++ java
C#根据经纬度请求返回坐标实际地址
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; using System.Net; using System.IO; using System.Configuration; using System.Xml; namespace WSGPSGateway.BLL { public class LocationAPI { public static string GetAddressByLatLng(string Lat, string Lng) { string CellUrl = "http://*******/CellAPI.aspx?Lat={0}&Lng={1}&Type=99"; string url = string.Format(CellUrl, Lat.ToString(), Lng.ToString()); string htm = GetPage(url); return htm; } public static string GetPage(string url) { if (url == "") return ""; WebResponse response = null; Stream stream = null; StreamReader reader = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.UserAgent = @"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.40607; .NET CLR 1.1.4322)"; request.Timeout = 5000; response = request.GetResponse(); stream = response.GetResponseStream(); if (Get_Chartset(response.Headers["Content-Type"].ToString()).ToLower() == "gbk") { reader = new StreamReader(stream, System.Text.Encoding.GetEncoding("GB2312")); } else if (Get_Chartset(response.Headers["Content-Type"].ToString()).ToLower() == "utf-8") { reader = new StreamReader(stream, System.Text.Encoding.UTF8); } else { reader = new StreamReader(stream, System.Text.Encoding.UTF8); } string buffer = reader.ReadToEnd(); return buffer; } catch (Exception ex) { DAL.Log.Write("google抓取数据失败异常! \0 错误记录:" + ex + "\r\n"); return ""; } finally { if (reader != null) reader.Close(); if (stream != null) stream.Close(); if (response != null) response.Close(); } } public static string Get_Chartset(string s) { if (s.ToLower() == "text/html") { return "gbk"; } else { int l = s.IndexOf("charset=") + 8; return s.Substring(l, s.Length - l); } } public string GetLatLng(string CID, string LAC) { string Url = "http://********/CellAPI.aspx?cid={0}&lac={1}"; Url = String.Format(Url, CID, LAC); string LatLng = ""; try { LatLng = BLL.LocationAPI.GetPage(Url); } catch (Exception ex) { DAL.Log.Write("获取基站地址发生错误! \0 错误记录:" + ex + "\r\n"); DAL.Log.Write("-----------------------------------------------------------\r\n"); } return LatLng; } } }
查看全文
相关阅读:
mysql分组排序取组内第一的数据行
C#版Nebula客户端编译
关于nginx
http状态码
gitlab
TCP/IP 3次握手和四次断开
nps 内网穿透
用CentOS7做一个简单的路由器
linux 简单特效
LVS粗讲
原文地址:https://www.cnblogs.com/javawebsoa/p/2458198.html
最新文章
C# DES 解密
为Azure-云准备一个基于Red Hat 8.x 的虚拟机镜像
关于linux系统时区的查看-修改与配置
vue (iview)根据权限控制columns 的某列显示与隐藏(通用)
MyBatis:条件构造器QueryWrapper方法详解
小知识
彻底解决JS处理Long类型精度丢失问题
Java String字符串转Json
linux 解压缩命令
excel poi操作例子 https://www.cnblogs.com/huajiezh/p/5467821.html
热门文章
jvisualvm配置
navicat破解
数据结构
数据结构
zookeeper + kafka集群安装部署文档
LINUX搭建VSFTP服务器
MySQL进阶系列:数据库设计中的范式究竟该如何使用
mysql进阶系列:表设计如何更好的选择数据类型
mysql进阶系列:mysql中MyISAM和InnoDB有什么区别
mysql进阶系列:mysql的存储引擎有什么区别,该怎么选择
Copyright © 2011-2022 走看看