抓页面的数据我知道
你可以试试看这个,请自行改一下网址= ="
public String IP() throws IOException{
String IP=null;
URL url = new URL("
http://iframe.ip138.com/ic.asp");
URLConnection conn = url.openConnection();
conn.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15");
conn.setRequestProperty("Content-Type", "text/html");
conn.setRequestProperty("Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
InputStream is = conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is,
"GB2312"));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
return IP;
}
追问有ajax 方法的么
追答抱歉那个我不会= ="
我只会抓原始码= ="
你试试看改这个,这个是读取文件格式我不知道可不可以这样用!!!
conn.setRequestProperty("Content-Type", "text/html");
conn.setRequestProperty("Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
本回答被提问者和网友采纳