怎么样把一个网址的内容读到一个文件中啊?哪位大侠帮帮忙,急那!!
怎么样把一个网址的内容读到一个文件中啊?哪位大侠帮帮忙,急那!!!
使用虚拟登陆到网站,然后就可以把整个网页的代码抓下来了。之后你可以存到TXT什么的里面。代码可以给你一部分。
String LOGON_SITE =
String LOGON_SITE_SEARCH =
int LOGON_PORT =
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
PostMethod post = new PostMethod("");
NameValuePair name = new NameValuePair();
NameValuePair pass = new NameValuePair();
post.setRequestBody(new NameValuePair[]{name,pass});
try{
int status = client.executeMethod(post);
}catch(Exception e)
{
}
post.releaseConnection();
//查看cookie信息
CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
Cookie[] cookies = cookiespec.match(LOGON_SITE, LOGON_PORT, "/", false, client.getState().getCookies());
if (cookies.length == 0) {
} else {
for (int i = 0; i < cookies.length; i++) {
}
}
GetMethod get = new GetMethod();
try{
client.executeMethod(get);
}catch(Exception x)
{