C#完成的中國挪動官網手機號碼收集器。本站提示廣大學習愛好者:(C#完成的中國挪動官網手機號碼收集器)文章只能為提供參考,不一定能成為您想要的結果。以下是C#完成的中國挪動官網手機號碼收集器正文
早幾天要換號碼,到挪動營業廳去辦說略微看的順眼的號碼就要預存若干若干。我認為好坑,然則在官網又找不到略微順眼的。無法之下沒方法寫了這個收集軟件。重要是想填補官網搜刮不便利的缺點。上面上代碼,比擬簡略:
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);