Csharp/C#教程:C#实现的中国移动官网手机号码采集器分享

早几天要换号码,到移动营业厅去办说稍微看的顺眼的号码就要预存多少多少。我觉得好坑,但是在官网又找不到稍微顺眼的。无奈之下没办法写了这个采集软件。主要是想弥补官网搜索不方便的缺陷。下面上代码,比较简单:

代码如下:
staticvoidMain(string[]args)
{
   string[]t={“134″,”135″,”136″,”137″,”138″,”139″,”147″,”150″,”151″,”152″,”157″,”158″,”159″,”182″,”183″,”187″,”188”};
   stringnumberPattern=@”<adata-original-title=””title=””>.*?)””(.*?)</a>”;
 
   for(inti=0;i<t.Length;i++)
   {
       intpageCount=1;
       intpage=0;
       stringpostdata=”page={0}&tdShopSelectionSuc.mobileType=0&tdShopSelectionSuc.selectArea=0731&tdShopSelectionSuc.selectAreaName=%E9%95%BF%E6%B2%99&tdShopSelectionSuc.numberSeg={1}________&tdShopSelectionSuc.numberRule=&tdShopSelectionSuc.searchStr=___________&tdShopSelectionSuc.endNumberRule=&tdShopSelectionSuc.storedValueStart=&tdShopSelectionSuc.storedValueEnd=&tdShopSelectionSuc.compositor=2&tdShopSelectionSuc.switchList=0&retryQuery=yes&numPriceSort=&numSort=1&pages.pageSize=15″;
       stringposturl=”https://www.hn.10086.cn/Shopping/selects/nos_queryPhoneInfo.action?timeStamp=”+((DateTime.Now.ToUniversalTime().Ticks-621355968000000000)/10000000)+””+newRandom().Next(100,999);
 
       for(intp=0;p<pageCount;p++)//翻页
       {
           Console.WriteLine(“正在获取{0}的所有号码,当前页码:{1}”,t[i],page);
           stringhtml=HttpHelper.GetHtml(posturl,string.Format(postdata,page,t[i]),true);
           if(html==””){continue;}
           if(pageCount==1)
           {
               pageCount=int.Parse(Regex.Match(html,@”varpageCount='(?.*?)’;”).Groups[“value”].Value);
           }
           MatchCollectionms=Regex.Matches(html,numberPattern);
           foreach(Matchminms)
           {
               stringnumber=m.Groups[“value”].ToString();
               if(!Exists(number))
               {
                   DbHelperSQL.ExecuteSql(“INSERTINTONumber(Number)VALUES(‘”+number+”‘)”);
               }
               Console.WriteLine(“号码:”+number);
           }
           page++;
       }
   }
   Console.WriteLine(“结束.”);
   Console.ReadKey();
}

既然号码采集到数据库了,那就顺便写个SQL把心仪的号码筛选出来吧:

ABAB型:

代码如下:
select*fromtelephonewhereSUBSTRING(telenumber,8,2)=SUBSTRING(telenumber,10,2)andSUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AABB型:

代码如下:
select*fromtelephonewhereSUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,9,1)andSUBSTRING(telenumber,10,1)=SUBSTRING(telenumber,11,1)andSUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AAAB型:

代码如下:
select*fromtelephonewhereSUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,9,1)andSUBSTRING(telenumber,9,1)=SUBSTRING(telenumber,10,1)andSUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

ABBB型:

代码如下:
select*fromtelephonewhereSUBSTRING(telenumber,9,1)=SUBSTRING(telenumber,10,1)andSUBSTRING(telenumber,11,1)=SUBSTRING(telenumber,10,1)andSUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AAAA型:

代码如下:
select*fromtelephonewhereSUBSTRING(telenumber,8,2)=SUBSTRING(telenumber,10,2)andSUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,11,1);

您可能感兴趣的文章:asp.net(c#)做一个网页数据采集工具C#结合数据库的数据采集器示例C#网页信息采集方法汇总Python制作爬虫采集小说Python采集腾讯新闻实例Python爬虫_城市公交、地铁站点和线路数据采集实例python实现自动登录人人网并采集信息的方法使用C#CefSharpPython采集某网站简历并且自动发送邀请短信的方法

标签: 手机 中国移动

C++自定义函数判断某年某月某日是这一年中第几天

浅谈c/c++中使用指针需要注意的问题

上述就是C#学习教程:C#实现的中国移动官网手机号码采集器分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/905863.html

(0)
上一篇 2021年10月23日
下一篇 2021年10月23日

精彩推荐