2008年10月16日 星期四

[Java]Get The Google's Searching Page


import java.net.*;
import java.io.*;
public class qwer {

/** Creates a new instance of Main */
public qwer() {}
public static void main(String[] args){
try{
Socket s = new Socket("images.google.com.tw", 80);
String head = "GET /images?gbv=2&um=1&complete=1&hl=zh-TW&lr=lang_zh-CN%7Clang_zh-TW&q=flower&aq=f HTTP/1.0\n" +
"Host: images.google.com.tw\n"+
"From: 2.1.1.1 HTTP/1.0\n"+
"Connection:close\n\n";
BufferedReader in = new BufferedReader(new
InputStreamReader(s.getInputStream()));
PrintWriter out = new PrintWriter(s.getOutputStream());
PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter("Test.txt")));


out.print(head);
out.flush();
String line="";
while ((line = in.readLine()) != null){
System.out.println(line);
output.println(line);
}
out.close();
output.close();
in.close();
}catch(Exception e){}
}}

沒有留言:

張貼留言