• 利用webservice获取所有手机号归属地


    添加一个http://api.showji.com/locating/Mobile.asmx的webservice引用

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Threading;
    using System.Data;
    using System.Data.SQLite;

    namespace GetMobileData
    {
    class GetData
    {
    publicvoid Get()
    {
    for (int i =0; i <=9; i++)
    {
    new Thread(new ParameterizedThreadStart(GetThread)).Start(i);
    }

    //List<MobileInfo> mInfos = new List<MobileInfo>();

    }

    privatevoid GetThread(object obj)
    {
    int nMobileBase =1300001;
    int nOffset =1300000;
    int i = (int)obj;

    nMobileBase
    += i *10000;
    nOffset
    += i *10000+9999;
    for (int j = nMobileBase; j < nOffset; j++)
    {
    MobileInfo mInfo
    =new MobileInfo();

    mInfo.MobileCode
    = j.ToString();
    MobileService.Mobile mobileSrv
    =new MobileService.Mobile();
    Console.WriteLine(
    "正在查询"+ j);
    mobileSrv.Query(j.ToString()
    +1234, out mInfo.Province, out mInfo.City, out mInfo.AreaCode, out mInfo.PostCode, out mInfo.CorpName, out mInfo.CardName);
    Console.WriteLine(
    "正在保存"+ j);
    SaveToDB(mInfo);
    }
    }

    privatevoid SaveToDB(MobileInfo mInfo)
    {
    SQLiteConnection liteConn
    =new SQLiteConnection("Data Source=E:\\UtilData\\mobile;Version=3;New=True;");
    liteConn.Open();


    string sSql ="INSERT INTO m_mobile_data (cMobileCode,cProvince,cCity,cAreaCode,cPostCode,cCorpName,cCardName)"+
    "VALUES(@MobileCode,@Province,@City,@AreaCode,@PostCode,@CorpName,@CardName)";

    SQLiteCommand liteCmd
    =new SQLiteCommand(liteConn);
    liteCmd.CommandText
    = sSql;

    //liteCmd.Parameters.
    SQLiteParameter litePara =new SQLiteParameter();
    litePara.ParameterName
    ="MobileCode";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.MobileCode;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="Province";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.Province;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="City";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.City;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="AreaCode";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.AreaCode;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="PostCode";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.PostCode;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="CorpName";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.CorpName;
    liteCmd.Parameters.Add(litePara);

    litePara
    =new SQLiteParameter();
    litePara.ParameterName
    ="CardName";
    litePara.DbType
    = DbType.String;
    litePara.Value
    = mInfo.CardName;
    liteCmd.Parameters.Add(litePara);

    liteCmd.ExecuteNonQuery();
    liteConn.Close();
    }
    }

    class MobileInfo
    {
    publicstring MobileCode;
    publicstring Province;
    publicstring City;
    publicstring AreaCode;
    publicstring PostCode;
    publicstring CorpName;
    publicstring CardName;
    }
    }

    打算在PSP上做应用
    所以使用的sqlite.
    开了10个线程,暂时先跑130到139段

  • 相关阅读:
    mysql 开启sql执行日志
    opcache.revalidate_freq 修改无效
    centos7 maven3.6.3安装
    CentOS7.5下基于FTP服务的局域网yum源搭建
    Centos7——防火墙(Firewall)开启常见端口命令
    Linux系统通过firewall限制或开放IP及端口
    CentOS7 FTP安装与配置
    centos7 搭建个人-企业私有云盘-seafile
    Centos6-7下杀毒软件clamav的安装和使用 (已成功测试)-----转发
    tomcat 安全规范(tomcat安全加固和规范1)--转发
  • 原文地址:https://www.cnblogs.com/icuit/p/1739573.html
Copyright © 2020-2023  润新知