Manually roll up the code and access the latest data of mobile phone number's home location (201911)

One day, the person in charge of a department, little sister: we need to identify the destination of the receiver's mobile phone number in the order, so that we can judge whether the customer placed the order maliciously by reference.
Move brick Jun: Yes, there are two plans;
I. purchase an API online (RMB support is required);
2. Find a mobile phone home database (free, may not be up-to-date);
Sister: I don't think the leader will sign the application for RMB, so it's free.
Move brick Jun: OK,(ten thousand in my heart at this time... (as you know));

 

 

 

Therefore, the most recent database of mobile phone number in a certain degree of search is actually the expert in the garden, and he gets excited instantly,

 

 


Open the link to see github, and think that you don't need to roll up the code to find the data. As a result, each folder has only query methods, but no library.
Further down, the original library has purchase links and upgrade links. It doesn't seem to work.

 

 

If you look at other search results of a certain degree, they are either not up-to-date, or charged, or you need to download points to log in.
I wish I could find an API interface to roll out his data Continue to query API interface of mobile phone number ownership,
After testing and comparison, four of them are available and reliable.

 

 

 

Start to roll up the code [sorry, please fill in the data source and data storage screen by yourself]:

private static List<string> MobileList = new List<string>();
// List of existing mobile phone number segments after the interruption
using (SqlConnection conn = new SqlConnection(ConStr))
{
    if (MobileList.Count == 0)
    {
        string temp_sql = $"SELECT [Mobile] From [App_Mobile_20191113]";
        using (SqlCommand command = new SqlCommand(temp_sql, conn))
        {
            command.CommandType = System.Data.CommandType.Text;
            if (conn.State == ConnectionState.Closed) conn.Open();
            using (SqlDataReader dreader = command.ExecuteReader())
            {
                while (dreader.Read())
                {
                    MobileList.Add(dreader[0].ToString());
                }
            }
        }
    }
}

First three digits of a number segment and one thread

List<Task> taskList = new List<Task>();
TaskFactory taskFactory = new TaskFactory();
// From 130 to 199
for (int i = 130; i < 200; i++)
{
    int mobile_no = i;
    taskList.Add(taskFactory.StartNew(() =>
    {
        Console.WriteLine($"{mobile_no} = {Thread.CurrentThread.ManagedThreadId}");
        Get(mobile_no);
    }));
}
Task.WaitAll(taskList.ToArray());

Start getting data

static void Get(int start_no)
{
    int start_mobile = int.Parse($"{start_no}0000");
    int end_mobile = int.Parse($"{start_no}9999");
    // Get all the number segments at the beginning, such as 1300000 - 1309999
    for (int i = start_mobile; i <= end_mobile; i++)
    {
        if (MobileList.Contains(i.ToString())) continue; //Existing number
        int code = new Random().Next(1000, 9999); // Last 4 digits of random mobile phone number
        string mobile = $"{i}{code}";
        //Get the data [sorry, the data source screen, please fill your brain by yourself]
        ModelMobile model = Get1(mobile); // Data source 1
        if (!model.QueryResult || string.IsNullOrWhiteSpace(model.Province)) model = Get2(mobile); // Data source 2
        if (!model.QueryResult || string.IsNullOrWhiteSpace(model.Province)) model = Get3(mobile); // Data source 3
        if (!model.QueryResult || string.IsNullOrWhiteSpace(model.Province)) model = Get4(mobile); // Data source 4
        //Enter the warehouse after obtaining success [please fill in the warehouse screen by yourself]
        if (model.QueryResult)
        {
            if (save_data(model))
                Console.WriteLine($" {Thread.CurrentThread.ManagedThreadId}. Success \t{i} = {model.Province} {model.City} ({model.Corp}) [{model.Source}] ......");
            else
                Console.WriteLine($" {Thread.CurrentThread.ManagedThreadId}. SaveFail \t{i} = {model.Province} {model.City} ({model.Corp}) [{model.Source}] ......");
        }
        else
            Console.WriteLine($" {Thread.CurrentThread.ManagedThreadId}. Fail \t{i} = {model.Message} [{model.Source}] ......");
    }
}

Operation effect:

 

After climbing all sections, the total number of data is 442245, more than the experts in the first garden of a certain degree.

 

 

 

As long as the source data is normal, the library can be upgraded normally all the time.
Roll code completed, dare to inform little sister quickly, it can be called normally.

Keywords: C# Mobile Database github

Added by aidude111 on Thu, 14 Nov 2019 10:48:10 +0200