易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA 爬网页用 例如:http://www.126.com

/*
Function name: myGetHttpFile2
Description: 爬网页用
Input: URL 例如:http://www.126.com
Output: 字符串,网页的HTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
PageURL = url ;
ArrayList urlCollection=new ArrayList();
Hashtable ht=new Hashtable();
//代理,如果要穿过代理将下面注释取消
//ht=System.getProperties();
//authentication = "Basic " + new sun.misc.BASE64Encoder().encode("代理的用户:代理的密码".getBytes());
//ht.put("proxySet", "true");
//ht.put("proxyHost", "172.16.20.2");
//ht.put("proxyPort", "80");

String urlSource=PageURL;
StringBuffer htmlBuffer=new StringBuffer();
String returnStr=null;
int codeStart=0;
int codeEnd=0;
int linkCount=0;

String getURL=null;
String realURL=null;
String urlText=null;
int from=0;
int lenURL=0;
int firstLink=0;
int endLink=0;
boolean isNewsLink=false;

try
{
URL su = new URL (urlSource);
URLConnection conn = su.openConnection();
//conn.setRequestProperty("Proxy-Authorization", authentication);

InputStream imageSource=new URL(urlSource).openStream();
int ch;
while((ch=imageSource.read())>-1)
{
htmlBuffer.append((char)ch);
}
imageSource.close();
returnStr= new String(htmlBuffer);
returnStr=new String(returnStr.getBytes("ISO8859_1"),"GBK");
}
catch(Exception e)
{
}

if(returnStr!=null){
return returnStr ;
}else{
return "empty" ;
}

}



相关文档:

java生成数字证书方法

Java 中生成数字证书也很简单的。
1、创建证书
Java 中的 keytool.exe (位于 JDKBin 目录下)可以用来创建数字证书,所有的数字证书是以一条一条(采用别名区别)的形式存入证书库的中,证书库中的一条证书包含该条证书的私钥,公钥和对应的数字证书的信息。证书库中的一条证书可以导出数字证书文件,数字证书文件只包括 ......

java笔试1

1. HttpSession session = request.getSession() 
与HttpSession session = request.getSession(true)的区别? 
参考答案: 
getSession(true)的函数原型为::HttpSession session = request.getSession (Boolean create) 
如果有与当前的request先关联的HttpSession,那么返回request相关联的HttpS ......

java 事物


一、什么是Java事务
  通常的观念认为,事务仅与数据库相关。
  事务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性(isolation)和持久性(durability)的缩写。事务的原子性表示事务执行过程中的任何失败都将导致事务所做的任何修改失效。一致性表示当事务执行失败 ......

JAVA字符串类

import java.util.*;
import java.util.regex.Pattern;
public class StrTools {
/**
* 分割字符串
*
* @param str String 原始字符串
* @param splitsign String 分隔符
* @return String[] 分割后的字符串数组
*/
@SuppressWarnings("unchecked")
public static String[] split(Stri ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号