对于测试,我想尝试使用该 java 代码获取 facebook 资源页面:它适用于除 facebook\twitter 之外的任何其他网站,有什么解决方案吗?
public class ReadWebPage {
public static void main(String[] args) {
String urltext = "http://www.facebook.com";
BufferedReader in = null;
try {
URL url = new URL(urltext);
in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}