1. [文件] awk.zip
2. [图片] 运行截图.jpg
3. [图片] 运行结果
4. [代码]存为bat双击打开即可
复制代码 代码如下:
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem 将IP提取到ip.txt文件
awk.exe "{a[$1]+=1;}END{for(i in a){print i;}}" 20120917.txt > ip.txt
rem 逐行读取ip.txt文件中的IP,并调用youdao.com的ip地址源查询接口
del result.txt
del last.txt
del last.csv
for /f "delims=" %%k in (ip.txt) do (
set /a b+=1
wget-1.10.2.exe "http://www.youdao.com/smartresult-xml/search.s?type=ip&q=%%k" --output-document=temp.xml >nul 2>nul
echo 正在处理%%k
for /f "delims=" %%i in (temp.xml) do (
set /a num+=1
set str=%%i
set str1=">%%k,!str!<"
if !num! equ 5 (echo !str1! | strrpc "<location>" "" | strrpc "</location>" "" result.txt)
)
set num=0
)
rem 处理result.txt引号
for /f "tokens=2 delims=>" %%z in ('type result.txt') do (
for /f "delims=<" %%z in ("%%z")do echo %%z last.txt
)
rem 将last.txt命名为last.csv
rename last.txt last.csv
pause
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!