国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#實現的中國移動官網手機號碼采集器

2020-01-24 02:18:18
字體:
來源:轉載
供稿:網友

早幾天要換號碼,到移動營業廳去辦說稍微看的順眼的號碼就要預存多少多少。我覺得好坑,但是在官網又找不到稍微順眼的。無奈之下沒辦法寫了這個采集軟件。主要是想彌補官網搜索不方便的缺陷。下面上代碼,比較簡單:

復制代碼 代碼如下:

static void Main(string[] args)
{
    string[] t = { "134", "135", "136", "137", "138", "139", "147", "150", "151", "152", "157", "158", "159", "182", "183", "187", "188" };
    string numberPattern = @"<a data-original-title="" title="">.*?)""(.*?)</a>";
 
    for (int i = 0; i < t.Length; i++)
    {
        int pageCount = 1;
        int page = 0;
        string postdata = "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";
        string posturl = "https://www.hn.10086.cn/Shopping/selects/nos_queryPhoneInfo.action?timeStamp=" + ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000) + "" + new Random().Next(100, 999);
 
        for (int p = 0; p < pageCount; p++)//翻頁
        {
            Console.WriteLine("正在獲取{0}的所有號碼,當前頁碼:{1}", t[i], page);
            string html = HttpHelper.GetHtml(posturl, string.Format(postdata, page, t[i]), true);
            if (html == "") { continue; }
            if (pageCount == 1)
            {
                pageCount = int.Parse(Regex.Match(html, @"var pageCount = '(?.*?)';").Groups["value"].Value);
            }
            MatchCollection ms = Regex.Matches(html, numberPattern);
            foreach (Match m in ms)
            {
                string number = m.Groups["value"].ToString();
                if (!Exists(number))
                {
                    DbHelperSQL.ExecuteSql("INSERT INTO Number(Number)VALUES('" + number + "')");
                }
                Console.WriteLine("號碼:" + number);
            }
            page++;
        }
    }
    Console.WriteLine("結束.");
    Console.ReadKey();
}

既然號碼采集到數據庫了,那就順便寫個SQL把心儀的號碼篩選出來吧:

ABAB型:

復制代碼 代碼如下:

select * from telephone where SUBSTRING(telenumber,8,2)=SUBSTRING(telenumber,10,2) and SUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AABB型:

復制代碼 代碼如下:

select * from telephone where SUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,9,1) and SUBSTRING(telenumber,10,1)=SUBSTRING(telenumber,11,1) and SUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AAAB型:

復制代碼 代碼如下:

select * from telephone where SUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,9,1) and SUBSTRING(telenumber,9,1)=SUBSTRING(telenumber,10,1) and SUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

ABBB型:

復制代碼 代碼如下:

select * from telephone where SUBSTRING(telenumber,9,1)=SUBSTRING(telenumber,10,1) and SUBSTRING(telenumber,11,1)=SUBSTRING(telenumber,10,1) and SUBSTRING(telenumber,8,1)!=SUBSTRING(telenumber,11,1);

AAAA型:

復制代碼 代碼如下:

select * from telephone where SUBSTRING(telenumber,8,2)=SUBSTRING(telenumber,10,2) and SUBSTRING(telenumber,8,1)=SUBSTRING(telenumber,11,1);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临沧市| 资中县| 会同县| 体育| 汾西县| 武隆县| 阳高县| 嵊州市| 达州市| 沙湾县| 柯坪县| 靖边县| 项城市| 湖北省| 依安县| 旬邑县| 安陆市| 大同县| 普陀区| 广安市| 赤城县| 湖口县| 确山县| 黑河市| 霍邱县| 肥西县| 虹口区| 三原县| 武穴市| 星座| 乐昌市| 如皋市| 图木舒克市| 临猗县| 桐梓县| 永济市| 台安县| 安吉县| 方山县| 酉阳| 玛多县|