发一个半成品,需要三方wget,且结果需要进一步处理。- @echo off&setlocal EnableDelayedExpansion&title 获取手机号码段
- if not exist UTF82ANSI.vbs cd.>UTF82ANSI.vbs&for /f "skip=5 tokens=1* delims=:" %%a in ('findstr /n .* %0') do if %%a lss 72 echo;%%b>>UTF82ANSI.vbs
- ::创建UFT-8转ANSI工具UTF82ANSI.vbs。注意生成编码的代码在第4以后,请修改行数+5
- echo 请将wegt与本程序置于同一目录后开始!&pause&goto start
-
- ' *============================================================================*
- ' * 批量编码转换包括GB2312,UTF-8,Unicode,支持拖动,可扩展到右菜单(发送到) *
- ' * CodeChange.vbs BY: yongfa365 http://www.yongfa365.com 2007-10-04 *
- ' * UTF82ANSI.vbs BY: fastslz http://bbs.cn-dos.net 2007-12-03 *
- ' *============================================================================*
- aCode = "UTF-8"
- bCode = "GB2312"
- Set objArgs = WScript.Arguments
- If objArgs.Count=0 Then
- MsgBox "本脚本仅支持"&aCode&"到"&bCode&"的转换,请将您要转换的文件拖到这个文件上! "&vbCrLf&"命令行用法:UTF82ANSI.vbs [驱动器][目录][文件名1][文件名2]...", vbInformation, "拖拽批量编码转换工具 BY: fastslz"
- End If
- For I = 0 To objArgs.Count - 1
- FileUrl = objArgs(I)
- Call CheckCode (FileUrl)
- Call WriteToFile(FileUrl, ReadFile(FileUrl, aCode), bCode)
- Next
- Function ReadFile(FileUrl, CharSet)
- Dim Str
- Set stm = CreateObject("Adodb.Stream")
- stm.Type = 2
- stm.mode = 3
- stm.charset = CharSet
- stm.Open
- stm.loadfromfile FileUrl
- Str = stm.readtext
- stm.Close
- Set stm = Nothing
- ReadFile = Str
- End Function
-
- Function WriteToFile (FileUrl, Str, CharSet)
- Set stm = CreateObject("Adodb.Stream")
- stm.Type = 2
- stm.mode = 3
- stm.charset = CharSet
- stm.Open
- stm.WriteText Str
- stm.SaveToFile FileUrl, 2
- stm.flush
- stm.Close
- Set stm = Nothing
- End Function
-
- Function CheckCode (FileUrl)
- Dim slz
- set slz = CreateObject("Adodb.Stream")
- slz.Type = 1
- slz.Mode = 3
- slz.Open
- slz.Position = 0
- slz.Loadfromfile FileUrl
- Bin=slz.read(2)
- if AscB(MidB(Bin,1,1))=&HEF and AscB(MidB(Bin,2,1))=&HBB Then
- Codes="UTF-8"
- elseif AscB(MidB(Bin,1,1))=&HFF and AscB(MidB(Bin,2,1))=&HFE Then
- Codes="Unicode"
- else
- Codes="GB2312"
- end if
- if not aCode = Codes Then
- MsgBox "待处理文件 “"&FileUrl&"”"&vbCrLf&"该文件原始编码不是"&aCode&",本脚本仅支持"&aCode&"到"&bCode&"的转换! ",vbInformation,"错误终止"
- WScript.Quit
- end if
- slz.Close
- set slz = Nothing
- End Function
-
- :start
-
- echo 开始执行 . . .
-
- set mnum=
- for %%a in (134 135) do (
- for /l %%i in (0,1,9) do (
- echo 下载号码段:%%a%%i
- set mnum=%%a%%i
- if not exist !mnum!.txt (
- wget -q "http://51sh.cc/index.php?type=code&sky=%%a%%i" -O %%a%%i.tmp
- call :UTA
- )
- pause&rem 此处用于流程控制,可去掉!
- )
- )
- ::号码段134 135 136 137 ……需要自己补充完整
-
- pause
- exit
-
- :UTA
- >"%temp%\dbg.tmp" (
- echo F100,102 EF BB BF
- echo RCX
- echo 3
- echo N %temp%\head.tmp
- echo W
- echo Q
- )
- debug<"%temp%\dbg.tmp" >nul
- chcp 936 >nul
- copy /b %temp%\head.tmp + /b !mnum!.tmp %temp%\head1.tmp >nul
- copy /b %temp%\head1.tmp !mnum!.txt >nul
- UTF82ANSI.vbs !mnum!.txt
- echo ------------------耐心等待----------------------
- cd.>OK_!mnum!.txt
- set sp=
- for /f "tokens=1,7-9 delims==><: " %%a in ('findstr /i /n "code province pcity" !mnum!.txt') do (
- echo %%a %%b %%c
- )>>OK_!mnum!.txt
- ::注意转换结果需要进一步调整
- echo ------------------转换完成----------------------
- goto :eof
-
- 以下备用参考:
- 中国移动手机号码段及号码
- 移动134号段: 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
- 移动135号段: 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
- 移动136号段: 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369
- 移动137号段: 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
- 移动138号段: 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
- 移动139号段: 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
- 移动150号段: 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
- 移动151号段: 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519
- 移动152号段: 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
- 移动157号段: 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579
- 移动158号段: 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589
- 移动159号段: 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
- 移动182号段: 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
- 移动187号段: 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879
- 移动188号段: 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889
- 中国联通手机号码段及号码
- 联通130号段: 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
- 联通131号段: 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
- 联通132号段: 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329
- 联通155号段: 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559
- 联通156号段: 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569
- 联通186号段: 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869
- 中国电信手机号码段及号码
- 电信133号段: 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
- 电信153号段: 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539
- 电信189号段: 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899
- 电信180号段: 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
复制代码
|