博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
利用webservice获取所有手机号归属地
阅读量:2505 次
发布时间:2019-05-11

本文共 2946 字,大约阅读时间需要 9 分钟。

添加一个的webservice引用

using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Threading;
using
System.Data;
using
System.Data.SQLite;
namespace
GetMobileData
{
class
GetData
{
public
void
Get()
{
for
(
int
i
=
0
; i
<=
9
; i
++
)
{
new
Thread(
new
ParameterizedThreadStart(GetThread)).Start(i);
}
//
List<MobileInfo> mInfos = new List<MobileInfo>();
}
private
void
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);
}
}
private
void
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
{
public
string
MobileCode;
public
string
Province;
public
string
City;
public
string
AreaCode;
public
string
PostCode;
public
string
CorpName;
public
string
CardName;
}
}

打算在PSP上做应用

所以使用的sqlite.
开了10个线程,暂时先跑130到139段

转载地址:http://dalgb.baihongyu.com/

你可能感兴趣的文章
从Vue.js窥探前端行业
查看>>
学习进度
查看>>
poj3368 RMQ
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>
Atitit.git的存储结构and 追踪
查看>>
atitit 读书与获取知识资料的attilax的总结.docx
查看>>
B站 React教程笔记day2(3)React-Redux
查看>>
找了一个api管理工具
查看>>
C++——string类和标准模板库
查看>>
zt C++ list 类学习笔记
查看>>
git常用命令
查看>>
探讨和比较Java和_NET的序列化_Serialization_框架
查看>>
1、jQuery概述
查看>>
数组比较大小的几种方法及math是方法
查看>>
FTP站点建立 普通电脑版&&服务器版
查看>>
js 给一段代码,给出运行后的最终结果的一些综合情况、
查看>>
webservice 详解
查看>>