通过网站域名获取该网站的源码
来源:互联网 发布:破解路由器密码的软件 编辑:程序博客网 时间:2024/05/17 17:56
package com.wallen.test;
import java.io.*;
import java.net.URL;
/**
* 通过网站域名获取该网站的源码
* @author Wallen
*
*/
public class Test2 {
public static void main(String[] args) {
Test2 t = new Test2();
t.getHTMLSrc("http://www.sina.com");
}
public void getHTMLSrc(String url){
InputStream openStream = null;
BufferedReader buf = null;
try {
String line = null;
URL theUrl= new URL(url);
openStream = theUrl.openStream();
/<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
//构建输入流的的字符集必须和HTML源码中的 charset一致
buf = new BufferedReader(new InputStreamReader(openStream,"utf-8"));
while((line = buf.readLine()) != null){
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally{
try {
if(openStream!=null){
openStream.close();
}
if(buf!=null){
buf.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.io.*;
import java.net.URL;
/**
* 通过网站域名获取该网站的源码
* @author Wallen
*
*/
public class Test2 {
public static void main(String[] args) {
Test2 t = new Test2();
t.getHTMLSrc("http://www.sina.com");
}
public void getHTMLSrc(String url){
InputStream openStream = null;
BufferedReader buf = null;
try {
String line = null;
URL theUrl= new URL(url);
openStream = theUrl.openStream();
/<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
//构建输入流的的字符集必须和HTML源码中的 charset一致
buf = new BufferedReader(new InputStreamReader(openStream,"utf-8"));
while((line = buf.readLine()) != null){
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally{
try {
if(openStream!=null){
openStream.close();
}
if(buf!=null){
buf.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
0 0
- 通过网站域名URL获取该网站的源码
- 通过网站域名获取该网站的源码
- 网站的域名该如何选择
- 通过域名访问网站的原理过程
- 通过ip查找域名的网站
- js获取网站域名
- 通过C#程序来获取网站源码,有些网站请求出错的解决方案。
- jsp获取网站域名 域名解析
- jsp获取网站域名 域名解析
- 域名最长的网站
- 我的网站域名
- 网站域名的选择
- 通过注入的恶意代码获取网站权限
- Tomcat发布一个网站通过域名访问
- 网站域名
- JS 获取网站根目录 域名+站名
- 快速构建网站之获取域名
- .net 获取本网站域名 以及得到字符串里包含的域名
- Struts2整合spring ,bean注入失败
- Handler简单上手
- 邓仰东专栏|机器学习的那些事儿(五):基于GPU的机器学习实例之IBM Waston
- 使用mongodb可视化管理软件adminMongo
- 汇编
- 通过网站域名获取该网站的源码
- Zookeeper使用--Java API
- 通过XmlDocument读写Xml文档
- VS2013配置proCC++开发环境
- tensorflow mac 安装教程
- Android 存储路径
- MAVEN创建多模块项目(水平与树形结构)
- iOS-获取webview的 url 和 title 和 html
- 非最大抑制(NMS)