C#實(shí)現(xiàn)的中國(guó)移動(dòng)官網(wǎng)手機(jī)號(hào)碼采集器
早幾天要換號(hào)碼,到移動(dòng)營(yíng)業(yè)廳去辦說稍微看的順眼的號(hào)碼就要預(yù)存多少多少。我覺得好坑,但是在官網(wǎng)又找不到稍微順眼的。無(wú)奈之下沒辦法寫了這個(gè)采集軟件。主要是想彌補(bǔ)官網(wǎng)搜索不方便的缺陷。下面上代碼,比較簡(jiǎn)單:
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++)//翻頁(yè)
{
Console.WriteLine("正在獲取{0}的所有號(hào)碼,當(dāng)前頁(yè)碼:{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("號(hào)碼:" + number);
}
page++;
}
}
Console.WriteLine("結(jié)束.");
Console.ReadKey();
}
既然號(hào)碼采集到數(shù)據(jù)庫(kù)了,那就順便寫個(gè)SQL把心儀的號(hào)碼篩選出來(lái)吧:
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);
- asp.net(c#)做一個(gè)網(wǎng)頁(yè)數(shù)據(jù)采集工具
- C#結(jié)合數(shù)據(jù)庫(kù)的數(shù)據(jù)采集器示例
- C#網(wǎng)頁(yè)信息采集方法匯總
- Python制作爬蟲采集小說
- Python采集騰訊新聞實(shí)例
- Python爬蟲_城市公交、地鐵站點(diǎn)和線路數(shù)據(jù)采集實(shí)例
- python實(shí)現(xiàn)自動(dòng)登錄人人網(wǎng)并采集信息的方法
- 使用C# CefSharp Python采集某網(wǎng)站簡(jiǎn)歷并且自動(dòng)發(fā)送邀請(qǐng)短信的方法
相關(guān)文章
采用C#實(shí)現(xiàn)軟件自動(dòng)更新的方法
這篇文章主要介紹了采用C#實(shí)現(xiàn)軟件自動(dòng)更新的方法,非常實(shí)用的功能,需要的朋友可以參考下2014-08-08Unity3D實(shí)現(xiàn)虛擬按鈕控制人物移動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Unity3D實(shí)現(xiàn)虛擬按鈕控制人物移動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-02-02C# 9 新特性——record的相關(guān)總結(jié)
這篇文章主要介紹了C# 9 新特性——record的相關(guān)總結(jié),幫助大家更好的理解和學(xué)習(xí)使用c# 9的新特性,感興趣的朋友可以了解下2021-02-02ADO.NET實(shí)體數(shù)據(jù)模型詳細(xì)介紹
本文將詳細(xì)介紹ADO.NET實(shí)體數(shù)據(jù)模型,下面先看看簡(jiǎn)單的單表的增刪改查操作,然后再看多表的關(guān)聯(lián)查詢,帶參數(shù)查詢等2012-11-11opencvsharp瑕疵檢測(cè)的實(shí)現(xiàn)示例
本文主要介紹了opencvsharp瑕疵檢測(cè)的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05C#使用Socket快速判斷數(shù)據(jù)庫(kù)連接是否正常的方法
這篇文章主要介紹了C#使用Socket快速判斷數(shù)據(jù)庫(kù)連接是否正常的方法,涉及C#中socket操作的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04