原来那个外网IP获取是通过swz8.com网站提取的
现在这网站已经关了 小弟从ip138找到了它的IP获取页面
但文字处理上 俺不大会 请帮忙完善
@echo off
title 获取本机内网和外网IP
if exist ip2city.asp del ip2city.asp
if exist ip.txt del ip.txt
if exist 1.txt del 1.txt
if exist 2.txt del 2.txt
wget http://www.ip138.com/ip2city.asp
ren ip2city.asp 1.txt
此时1.txt内容为
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title> 您的IP地址 </title>
</head>
<body style="margin:0px"><center>您的IP地址是: 来自:湖南省株洲市 电信</center></body></html>
以下再用SED提取
sed -r "s/(+\.+\.+\.+).*/\n\1/;s/^.*\n//" 1.txt >2.txt
for /f %%i in (2.txt) do set i=%%i
echo %i% >ip.txt
start ip.txt
IP.txt内容为
1.1.1.1空格接回车
我是新手 请高手帮忙精简完善 去掉IP.TXT的空格接回车
The original that the external network IP acquisition was through the swz8.com website extraction
Now this website has been closed. The younger brother found its IP acquisition page from ip138
But I don't know much about text processing. Please help improve it
@echo off
title Get local intranet and external network IP
if exist ip2city.asp del ip2city.asp
if exist ip.txt del ip.txt
if exist 1.txt del 1.txt
if exist 2.txt del 2.txt
wget http://www.ip138.com/ip2city.asp
ren ip2city.asp 1.txt
At this time, the content of 1.txt is
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title> Your IP address </title>
</head>
<body style="margin:0px"><center>Your IP address is: From: Zhuzhou City, Hunan Province Telecom</center></body></html>
The following is to extract with SED
sed -r "s/(+\.+\.+\.+).*/\n\1/;s/^.*\n//" 1.txt >2.txt
for /f %%i in (2.txt) do set i=%%i
echo %i% >ip.txt
start ip.txt
The content of IP.txt is
1.1.1.1 space followed by carriage return
I'm a novice. Please help the master to simplify and improve, and remove the space followed by carriage return in IP.TXT