Package org.vietspider.chars

Examples of org.vietspider.chars.URLEncoder


  private static WebClient webClient = new WebClient();
 
  private static byte[] loadContent(String address) throws Exception {
    webClient.setURL(address, new URL(address));
    HttpGet httpGet = null;
    URLEncoder urlEncoder = new URLEncoder();
    address = urlEncoder.encode(address);
    httpGet = webClient.createGetMethod(address, "");

    if(httpGet == null) return null;
    HttpHost httpHost = webClient.createHttpHost(address);
    HttpResponse httpResponse = webClient.execute(httpHost, httpGet);
View Full Code Here


//    methodHandler.setTimeout(30);
//  }
 
  public static byte[] loadContent(String address) throws Exception {
    try{
      URLEncoder urlEncoder = new URLEncoder();
      address = urlEncoder.encode(address);
     
      HttpResponse httpResponse = methodHandler.execute(address, "");
     
      HttpResponseReader httpResponseReader = HttpHandlers.getInstance().createReader();
      return httpResponseReader.readBody(httpResponse);
View Full Code Here

    HttpGet httpGet = currentGets.remove(address);
    if(httpGet != null) httpGet.abort();
  }

  public byte[] loadContent(String referer, String address) throws Exception {
    URLEncoder urlEncoder = new URLEncoder();
   
    if(host == null) {
      setURL(referer, new URL(address));
    } else {
      URL url = new URL(address)
      URLCodeGenerator urlCodeUtil = new URLCodeGenerator();
      if(!urlCodeUtil.compareHost(url.getHost(), getHost())) {
        setURL(referer, new URL(address));
      }
    }

    HttpGet httpGet = null;
    try {
      address = urlEncoder.encode(address);
      httpGet = createGetMethod(address, referer);     
      currentGets.put(address, httpGet);

      if(httpGet == null) return null;
      HttpHost httpHost = createHttpHost(address);
View Full Code Here

      this.httpHost = webClient.createHttpHost(address);
      return execute(webClient.createPostMethod(address, referer, params));
      //    System.out.println(httpGet.getFirstHeader("User-Agent").getValue().trim());
    } catch (URISyntaxException e) {
      //encode url
      URLEncoder encoder = new URLEncoder();
      address = encoder.encode(address);
      try {
        this.httpHost = webClient.createHttpHost(address);
        return execute(webClient.createPostMethod(address, referer, params));
      } catch (URISyntaxException se) {
        LogService.getInstance().setMessage(se, "1.Get method handler: " + address);
View Full Code Here

      return null;
    }
  }

  private HttpResponse executeEncodeURL (String address, String referer) throws Exception {
    URLEncoder encoder = new URLEncoder();
    address = encoder.encode(address);
    try {
      this.httpHost = webClient.createHttpHost(address);
      return execute(webClient.createGetMethod(address, referer));
    } catch (URISyntaxException se) {
      LogService.getInstance().setMessage(se, "4.Get method handler: " + address);
View Full Code Here

      this.httpHost = webClient.createHttpHost(address);
      return execute(webClient.createPostMethod(address, referer, params));
//    System.out.println(httpGet.getFirstHeader("User-Agent").getValue().trim());
    } catch (URISyntaxException e) {
      //encode url
      URLEncoder encoder = new URLEncoder();
      address = encoder.encode(address);
      try {
        this.httpHost = webClient.createHttpHost(address);
        return execute(webClient.createPostMethod(address, referer, params));
      } catch (URISyntaxException se) {
        LogService.getInstance().setMessage(se, "1.Get method handler: " + address);
View Full Code Here

      return null;
    }
  }

  private HttpResponse executeEncodeURL (String address, String referer) throws Exception {
    URLEncoder encoder = new URLEncoder();
    address = encoder.encode(address);
    try {
      this.httpHost = webClient.createHttpHost(address);
      return execute(webClient.createGetMethod(address, referer));
    } catch (URISyntaxException se) {
      LogService.getInstance().setMessage(se, "4.Get method handler: " + address);
View Full Code Here

TOP

Related Classes of org.vietspider.chars.URLEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.