PHP写了个卡死鸟,可能水平低,擦,找了段JAVA代码,改了改,效果还行
package jdbc;
import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class http{
public static void main(String argv[]) throws Exception {
FileReader fr=new FileReader("d:\\ok.txt");
BufferedReader br=new BufferedReader(fr);
//int i=0;
final int HTTP_PORT = 80;
String line1=null;
while((line1=br.readLine())!=null){
//String host = br.readLine();
//String host1=host.trim();
//System.out.println(line.trim());
//i++;
//System.out.println(i);
try {
Socket socket = new Socket(line1, 80);
boolean autoflush = true;
PrintWriter out = new PrintWriter(socket.getOutputStream(), autoflush);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//send an HTTP request to the web server
out.println("GET /1111 HTTP/1.1");
out.println("Host: "+line1);
out.println("Connection: Close");
out.println();
//read the response
boolean loop = true;
StringBuffer sb = new StringBuffer(8096);
while (loop) {
if (in.ready()) {
int i = 0;
while (i != -1) {
i = in.read();
sb.append((char) i);
}
loop = false;
}
//Thread.currentThread().sleep(50);
}
//display the response to the out console
String body=sb.toString();
String regEx="Physical Path(.*)1111";
Pattern pat=Pattern.compile(regEx);
Matcher mat=pat.matcher(body);
while(mat.find())
{
System.out.println(mat.group());
}
//boolean result=Pattern.compile(regEx).matcher(body).find();
//System.out.println(mat.group());
//System.out.println(sb.toString());
socket.close();
} catch (UnknownHostException e) {
System.err.println("Don't know about host: Victest.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for " + "the connection to: Victest.");
System.exit(1);
}
}
}
}
http://www.dengb.com/Javabc/530740.htmlwww.dengb.comtruehttp://www.dengb.com/Javabc/530740.htmlTechArticlePHP写了个卡死鸟,可能水平低,擦,找了段JAVA代码,改了改,效果还行 package jdbc; import java.io.*; import java.net.Socket; import java.net.UnknownHostExc...