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; } } }
查看全文
相关阅读:
【黑客免杀攻防】读书笔记2
【逆向工具】IDA使用5-( string、图形化与视图的切换、图形化显示反汇编地址、自动注释、标签使用)
定位内网中毒主机IP经历小记
【黑客免杀攻防】读书笔记1
对HUAWEI-ManagedProvisioning的一次不完整分析
【PE结构】由浅入深PE基础学习-菜鸟手动查询导出表、相对虚拟地址(RVA)与文件偏移地址转换(FOA)
一份通过IPC$和lpk.dll感染方式的病毒分析报告
浅析
HTTP协议/RTSP协议/RTMP协议的区别
iOS
原文地址:https://www.cnblogs.com/javawebsoa/p/2458198.html
最新文章
E437: terminal capability "cm" required
'vt100': unknown terminal type.
Linux环境变量的设置和查看方法
vncserver 添加用户
mysql 增加删除用户
linux上很方便的上传下载文件工具rz和sz
nginx+ tomcat集群+动静资源分离
C#中哈希表(HashTable)的用法详解以及和Dictionary比较
在DataTable中执行DataTable.Select("条件"),
SqlDataAdapter 用法详解
热门文章
ExecuteNonQuery,ExecuteReader,ExecuteScalar 区别
JavaScript用JQuery呼叫Server端方法
C#中[WebMethod]的用法,aspx、ashx、asmx
[WebMethod]的使用,ajax调用[WebMethod]的使用,webservice(web服务) asmx的使用,ajax调用[WebMethod]进行json传输
GridView控件RowDataBound事件中获取列字段值的几种途径
GridView 中RowDataBound 获取绑定后的各个字段的值
在GridView的RowDataBound事件中获取某行某列的值!
【工具】大量病毒样本取样工作经验1(重复样本排除、分析方法)
恶意PDF文档分析记录
调试脚本病毒
Copyright © 2011-2022 走看看