当前位置: 首页 > news >正文

网站的推广等内容常州百度网站排名优化

网站的推广等内容,常州百度网站排名优化,仿v2ex wordpress,阿里云 拦截网站商业收费 百度地图高德地图腾讯地图纯真IP 开源免费 纯真ip免费版 以前可以直接下载#xff0c;现在获取ip数据库的方式改变了#xff0c;自行官网查看把#xff0c;个人或者学术研究#xff0c;商用追责#xff0c;商业用途慎用 using System.Collections.Generic; us…商业收费 百度地图高德地图腾讯地图纯真IP 开源免费 纯真ip免费版 以前可以直接下载现在获取ip数据库的方式改变了自行官网查看把个人或者学术研究商用追责商业用途慎用 using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; using System; using Microsoft.Extensions.Options; using Youhuo.ConfigModel; using System.Text.RegularExpressions;namespace Stu01 {public class IPSearchHelper{private readonly IOptionsChunZhenSetting options;System.IO.FileStream ipFile;long ip;public IPSearchHelper(IOptionsChunZhenSetting options){this.options options;}///summary/// 地理位置,包括国家和地区////summarypublic struct IPLocation{public string country, area;}///summary/// 获取指定IP所在地理位置////summary///param namestrIP要查询的IP地址/param///returns/returnspublic IPLocation GetIPLocation(string strIP){IPLocation loc new IPLocation();//return loc;if (string.IsNullOrEmpty(strIP)){return loc;}var match Regex.Match(strIP, ^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$);if (!match.Success){return loc;}ip IPToLong(strIP);var RegexStr (^[\/\\].*)|(.*:.*);//判断是不是绝对路径,options.Value.DatPath纯真数据库存放的路径if (System.Text.RegularExpressions.Regex.IsMatch(options.Value.DatPath, RegexStr)){ipFile new System.IO.FileStream(options.Value.DatPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);}else{var fullPath Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options.Value.DatPath);ipFile new System.IO.FileStream(fullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);}long[] ipArray BlockToArray(ReadIPBlock());long offset SearchIP(ipArray, 0, ipArray.Length - 1) * 7 4;ipFile.Position offset;//跳过起始IPipFile.Position ReadLongX(3) 4;//跳过结束IPint flag ipFile.ReadByte();//读取标志if (flag 1)//表示国家和地区被转向{ipFile.Position ReadLongX(3);flag ipFile.ReadByte();//再读标志}long countryOffset ipFile.Position;loc.country ReadString(flag);if (flag 2){ipFile.Position countryOffset 3;}flag ipFile.ReadByte();loc.area ReadString(flag);ipFile.Close();ipFile null;return loc;}///summary/// 将字符串形式的IP转换位long////summary///param namestrIP/param///returns/returnspublic long IPToLong(string strIP){if (strIP.Equals(::1)){strIP 127.0.0.1;}byte[] ip_bytes new byte[8];string[] strArr strIP.Split(new char[] { . });if (strArr.Length 1){return 0;}byte tmpNumber;for (int i 0; i 4; i){var res byte.TryParse(strArr[3 - i], out tmpNumber);ip_bytes[i] res ? tmpNumber : (byte)0;}return BitConverter.ToInt64(ip_bytes, 0);}///summary/// 将索引区字节块中的起始IP转换成Long数组////summary///param nameipBlock/paramlong[] BlockToArray(byte[] ipBlock){long[] ipArray new long[ipBlock.Length / 7];int ipIndex 0;byte[] temp new byte[8];for (int i 0; i ipBlock.Length; i 7){Array.Copy(ipBlock, i, temp, 0, 4);ipArray[ipIndex] BitConverter.ToInt64(temp, 0);ipIndex;}return ipArray;}///summary/// 从IP数组中搜索指定IP并返回其索引////summary///param nameipArrayIP数组/param///param namestart指定搜索的起始位置/param///param nameend指定搜索的结束位置/param///returns/returnsint SearchIP(long[] ipArray, int start, int end){int middle (start end) / 2;if (middle start)return middle;else if (ip ipArray[middle])return SearchIP(ipArray, start, middle);elsereturn SearchIP(ipArray, middle, end);}///summary/// 读取IP文件中索引区块////summary///returns/returnsbyte[] ReadIPBlock(){long startPosition ReadLongX(4);long endPosition ReadLongX(4);long count (endPosition - startPosition) / 7 1;//总记录数ipFile.Position startPosition;byte[] ipBlock new byte[count * 7];ipFile.Read(ipBlock, 0, ipBlock.Length);ipFile.Position startPosition;return ipBlock;}///summary/// 从IP文件中读取指定字节并转换位long////summary///param namebytesCount需要转换的字节数主意不要超过8字节/param///returns/returnslong ReadLongX(int bytesCount){byte[] _bytes new byte[8];ipFile.Read(_bytes, 0, bytesCount);return BitConverter.ToInt64(_bytes, 0);}///summary/// 从IP文件中读取字符串////summary///param nameflag转向标志/param///returns/returnsstring ReadString(int flag){if (flag 1 || flag 2)//转向标志ipFile.Position ReadLongX(3);elseipFile.Position - 1;Listbyte list new Listbyte();byte b (byte)ipFile.ReadByte();while (b 0){list.Add(b);b (byte)ipFile.ReadByte();}Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);return Encoding.GetEncoding(GB2312).GetString(list.ToArray());}} } 但是有高并发问题 ip2region 提供了多种语言的支持更新频率高支持高并发 Install-Package IP2Region.Net下载保存xdbhttps://github.com/lionsoul2014/ip2region/blob/master/data/ip2region.xdb //这里为啥直接填写ip2region.xdb因为用了始终复制 ISearcher searcher new Searcher(CachePolicy.File, ip2region.xdb); var ipResult searcher.Search(123.232.22.18);iptools C#版本简单易用支持高并发响应快但是更新频率不高 Install-Package IPTools.China下载ip数据库https://github.com/stulzq/IPTools/raw/master/db/ip2region.db设置为始终复制 运行代码即可 IpTool.Search(your ip address);结果 {IpAddress:123.232.22.18,Country:中国,CountryCode:null,Province:山东,ProvinceCode:null,City:济南,PostCode:null,NetworkOperator:联通,Latitude:0,Longitude:0,AccuracyRadius:null }
http://www.hkea.cn/news/14511915/

相关文章:

  • 企业网站栏目设置网站建设 目标
  • 网站开发的软件环境有哪些哪里找做网站客户
  • 湖北专业的网瘾戒除学校收费标准长沙快速排名优化
  • 建设银行北京招聘网站网站开发最流行的语言
  • 建设网站需要多少钱济南兴田德润o厉害吗网络设计的三个层次
  • 赣州网站建设怎么样中国建筑网建设通查询证件网
  • 做游戏还是做网站好机器配件做外贸上什么网站
  • 做网站后台开发工资我要做自媒体要怎么开始
  • seo网站排名全选湖南网站建设推荐
  • 网站做联盟广告能赚钱吗朝阳公司做网站
  • 农业特色网站建设一级a做爰片免费的网站有吗
  • 海南第六建设工程有限公司网站怎么开发一个网页
  • 西宁网站设计公司价格设计网站意味着什么
  • 上海网站建设专业公司哪家好兰溪企业网站搭建地址
  • 沈阳网站开发程序员工资无锡网站建设企业
  • 做暖dnf动态ufo网站青岛全网推广怎么做
  • 可以在线做c语言的网站wordpress照片评选插件
  • 怎么让google收录网站网站建设培训资料
  • 网站模板 双语制作棋牌app软件要多少钱
  • 知科网站免费推广平台有哪些
  • 如何查找网站济源网站开发
  • 成都网站托管网站建设 管理
  • 阿里巴巴国际站外贸流程阿狸网站建设
  • 网站建设技术入股协议云浮网站网站建设
  • 关注网站怎么做湛江模板建站平台
  • 推广网站设计推广方案网易企业邮箱属于什么类型
  • 百度权重排名高的网站销售型网站营销目标
  • it公司怎么在国外网站做宣传宝安网站改版
  • 公司以优化为理由裁员合法吗yoast wordpress seo
  • 装修网站cms微信客户端官网