• 大小: 35KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Java
  • 标签:

资源简介

java实现京东模拟登录,进行添加身份信息,购买机票信息。

资源截图

代码片段和文件信息

package downfa;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.httpclient.Cookie;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomText;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlBody;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
import com.gargoylesoftware.htmlunit.html.HtmlImage;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSpan;
import com.gargoylesoftware.htmlunit.html.HtmlStrong;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
/**
 * 文档处理类
 *
 */
public class Document {
private static final Logger LOGGER = Logger.getLogger(Document.class);
public static WebClient client = null;
private static SimpleDateFormat dateFormat1 = new SimpleDateFormat(“yyyy/MM/dd/“);

static{
LOGGER.info(“openWebClient“);
// client = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
client = new WebClient(BrowserVersion.CHROME);
client.getOptions().setThrowExceptionOnscriptError(false);
//client.getOptions().setjavascriptEnabled(true);
//client.getOptions().setCssEnabled(false);
client.getOptions().setThrowExceptionOnscriptError(false);
client.getOptions().setUseInsecureSSL(true);
client.getOptions().setjavascriptEnabled(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.getOptions().setCssEnabled(false);
client.getOptions().setRedirectEnabled(true);
client.getOptions().setActiveXNative(false); 
client.setAjaxController(new NicelyResynchronizingAjaxController());  
// LogFactory.getFactory().setAttribute(“org.apache.commons.logging.Log““org.apache.commons.logging.impl.NoOpLog“);   
// java.util.logging.Logger.getLogger(“net.sourceforge.htmlunit“).setLevel(java.util.logging.Level.OFF);

}
/**
 * 获得Html 页面
 * @param url 链接
 * @return
 * @throws IOException 
 * @throws MalformedURLException 
 * @throws FailingHttpStatusCodeExcepti

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      15369  2018-07-09 10:26  Document.java

     文件      56031  2018-08-06 17:26  bbbb.html

     文件      43263  2018-08-07 14:06  HttpClientLogin3.java

     文件      24663  2018-08-06 17:26  aaaa.txt

----------- ---------  ---------- -----  ----

               139326                    4


评论

共有 条评论