我刚刚开始使用网络分配,并且我已经卡住了。 作业要求我检查用户提供的网站链接,并通过阅读标题信息来确定它们是否处于活动或不活动状态。 到目前为止,谷歌搜索后,我只是有这个代码检索网站。我不知道如何查看这些信息并查找HTML链接。 这里是代码:如何从URL中获取HTML链接
import java.net.*;
import java.io.*;
public class url_checker {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://yahoo.com");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
int count = 0;
while ((inputLine = in.readLine()) != null) {
System.out.println (inputLine);
}
in.close();
}
}
请帮忙。 谢谢!
感谢您的回复!我在查找用户提供的网页上的链接时遇到问题。在确定了所有链接后,我将使用您的方法。 – 2011-02-07 02:26:29