當前位置: 首頁>>代碼示例>>Java>>正文


Java Connection.execute方法代碼示例

本文整理匯總了Java中org.jsoup.Connection.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.execute方法的具體用法?Java Connection.execute怎麽用?Java Connection.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jsoup.Connection的用法示例。


在下文中一共展示了Connection.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: authentificationKi

import org.jsoup.Connection; //導入方法依賴的package包/類
/**
   * Handle authentification if needed for cookie
   * @return
   * @throws IOException
   */
  public static Map<String, String> authentificationKi() throws IOException {
      Connection.Response res = null;
      if (AuthentificationParam.AUTHENFICATION.isValue()) {
          Connection conn = getConnection(CommonConst.URL_AUTH_KRALAND, null, null);
          conn.data("p1", AuthentificationParam.KI_SLAVE_LOGIN.getValue(), "p2", AuthentificationParam.KI_SLAVE_PASS.getValue(),
                  "Submit", "Ok").method(Method.POST).execute();
          res = conn.execute();
      } else {
          res = getConnection(CommonConst.URL_KRALAND_MAIN, null, null).execute();
      }
      Map<String, String> cookies = res.cookies();

logger.debug("cookies: {}", cookies);
return cookies;
  }
 
開發者ID:KralandCE,項目名稱:krapi-core,代碼行數:21,代碼來源:Util.java

示例2: postHtmlFile

import org.jsoup.Connection; //導入方法依賴的package包/類
/**
 * Test fetching a form, and submitting it with a file attached.
 */
@Test
public void postHtmlFile() throws IOException {
    Document index = Jsoup.connect("http://direct.infohound.net/tidy/").get();
    FormElement form = index.select("[name=tidy]").forms().get(0);
    Connection post = form.submit();

    File uploadFile = ParseTest.getFile("/htmltests/google-ipod.html");
    FileInputStream stream = new FileInputStream(uploadFile);
    
    Connection.KeyVal fileData = post.data("_file");
    fileData.value("check.html");
    fileData.inputStream(stream);

    Connection.Response res;
    try {
        res = post.execute();
    } finally {
        stream.close();
    }

    Document out = res.parse();
    assertTrue(out.text().contains("HTML Tidy Complete"));
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:27,代碼來源:UrlConnectTest.java

示例3: main

import org.jsoup.Connection; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
//        Connection connection = Jsoup.connect("http://bluetata.com");

//        // connection.data("aaa","ccc");  // 這是重點
//
//        connection.header("Content-Type", "application/json; charset=UTF-8");  // 這是重點
//
//        connection.header("Accept", "text/plain, */*; q=0.01");  
//
//        connection.timeout(15000);  
//
//        //String body = "{\"CategoryType\":\"SiteHome\",\"ParentCategoryId\":0,\"CategoryId\":808,\"PageIndex\":2,\"TotalPostCount\":4000,\"ItemListActionName\":\"PostList\"}"; 
//
//        //connection.requestBody(body);  
//
//        Document document = connection.post();
        
        
        String jsonBody = "{\"name\":\"ACTIVATE\",\"value\":\"E0010\"}";
        
        Connection connection = Jsoup.connect("http://bluetata.com/")
                .userAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36") // User-Agent of Chrome 55
                .referrer("http://bluetata.com/")
                .header("Content-Type", "application/json; charset=UTF-8")
                .header("Accept", "text/plain, */*; q=0.01")
                .header("Accept-Encoding", "gzip,deflate,sdch")
                .header("Accept-Language", "es-ES,es;q=0.8")
                .header("Connection", "keep-alive")
                .header("X-Requested-With", "XMLHttpRequest")
                .requestBody(jsonBody)
                .maxBodySize(100)
                .timeout(1000 * 10)
                .method(Connection.Method.POST);

        Response response = connection.execute();
        
        
    }
 
開發者ID:bluetata,項目名稱:crawler-jsoup-maven,代碼行數:40,代碼來源:TestApiOfConnect.java

示例4: connect

import org.jsoup.Connection; //導入方法依賴的package包/類
private Connection.Response connect() throws IOException {
    String url = "https://www.steamgifts.com/discussion/" + discussionId + "/search?page=" + page;
    Log.v(TAG, "Fetching discussion details for " + url);
    Connection connection = Jsoup.connect(url)
            .userAgent(Constants.JSOUP_USER_AGENT)
            .timeout(Constants.JSOUP_TIMEOUT)
            .followRedirects(true);

    if (SteamGiftsUserData.getCurrent(fragment.getContext()).isLoggedIn())
        connection.cookie("PHPSESSID", SteamGiftsUserData.getCurrent(fragment.getContext()).getSessionId());

    return connection.execute();
}
 
開發者ID:SteamGifts,項目名稱:SteamGifts,代碼行數:14,代碼來源:LoadDiscussionDetailsTask.java

示例5: getGroupsList

import org.jsoup.Connection; //導入方法依賴的package包/類
@Override
public ArrayList<Group> getGroupsList(Component c, Context context, String id, String pwd) throws IOException {
    ArrayList<Group> liste = new ArrayList<>();
    String nameComponent = String.copyValueOf(c.name.toCharArray());

    String url = c.groups_url;
    Connection conn = Jsoup.connect(url);
    String login = id+":"+pwd;
    String b64login = new String(android.util.Base64.encode(login.getBytes(), android.util.Base64.DEFAULT));
    conn.header("Authorization", "Basic " + b64login);

    Connection.Response resp = conn.execute();
    if(resp.statusCode() == 200){
        if(AuthManager.needAccount(nameComponent, context)) {
            AuthManager.addAccount(id, pwd, nameComponent, context);
        }
    }

    Document doc = conn.get();
    for (Element e : doc.select("option[value$=.html]"))
    {
        Group groupe = new Group();
        groupe.name = e.text();
        groupe.dataSourceType = DataSourceType.CELCAT;
        groupe.dataSource = getRefactoredUrl(url)+(e.attr("value").replaceAll(".html", ".xml"));

        groupe.component = c;
        liste.add(groupe);
    }
    return liste;
}
 
開發者ID:natinusala,項目名稱:openedt,代碼行數:32,代碼來源:CelcatAdapter.java

示例6: sendHeadRequest

import org.jsoup.Connection; //導入方法依賴的package包/類
@Test
public void sendHeadRequest() throws IOException {
    String url = "http://direct.infohound.net/tools/parse-xml.xml";
    Connection con = Jsoup.connect(url).method(Connection.Method.HEAD);
    final Connection.Response response = con.execute();
    assertEquals("text/xml", response.header("Content-Type"));
    assertEquals("", response.body()); // head ought to have no body
    Document doc = response.parse();
    assertEquals("", doc.text());
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:11,代碼來源:UrlConnectTest.java

示例7: sendRequest

import org.jsoup.Connection; //導入方法依賴的package包/類
private Response sendRequest(Method method, String apiPath, boolean absoluteApiPath, String... keyval) throws IOException {
  String url = absoluteApiPath ? apiPath : SERVER_HOSTNAME + apiPath;
  Connection conn = Jsoup.connect(url).maxBodySize(100 * 1024 * 1024).timeout(10000).method(method).ignoreContentType(true).ignoreHttpErrors(true);
  logger.finest("Sending " + method + " request at " + url);
  if (skypeToken != null) {
    conn.header("X-Skypetoken", skypeToken);
  } else {
    logger.fine("No token sent for the request at: " + url);
  }
  conn.data(keyval);
  return conn.execute();
}
 
開發者ID:delthas,項目名稱:JavaSkype,代碼行數:13,代碼來源:WebConnector.java

示例8: changePassword

import org.jsoup.Connection; //導入方法依賴的package包/類
/**
 * 修改密碼
 * @param oldPass 原始密碼
 * @param newPass1 新設密碼
 * @param newPass2 再次輸入的新設密碼
 * @return 錯誤代碼
 */
public String changePassword(UserEntity uData,String oldPass, String newPass1,String newPass2) {
    try {
        String session = getSession(uData, false);
        if (session.length() <= 3) {
            session = getSession(uData, true);
        }

        Connection con = Jsoup.connect("http://202.115.47.141/modifyPassWordAction.do?oper=xgmm")
                .cookie("JSESSIONID", session)
                .data("yhlbdm", "01")
                .data("zjh", uData.getNum())
                .data("oldPass", oldPass)
                .data("newPass1",newPass1)
                .data("newPass2",newPass2)
                .timeout(10000)
                .method(Connection.Method.POST);
        Response response = con.execute();
        Document doc = response.parse();

        Elements prompt = doc.getElementsContainingText("!");
        String strong = prompt.text().trim();

        if(strong.contains("輸入的當前密碼"))
        {
            return "101";	// TODO 錯誤代碼101:原始密碼輸入
        }
        else if(strong.contains("密碼不正確"))
        {
            return "102";	// TODO 錯誤代碼102:密碼不正確
        } else
        {
            return session; // TODO 修改成功
        }
    } catch (Exception e)
    {
        return "104"; // TODO 錯誤代碼104:連接超時或其他異常
    }
}
 
開發者ID:CrazyRunning,項目名稱:MyStudyHelper,代碼行數:46,代碼來源:NetUtil.java

示例9: getZeakdata

import org.jsoup.Connection; //導入方法依賴的package包/類
private Document getZeakdata(String getURL) {

            Document dd = null;

            try {
                //disableSSLCertCheck();
                Connection connection3 = HttpConnection.connect(getURL)
                        .cookies(cooca)
                        .ignoreHttpErrors(true)
                        .ignoreContentType(true)
                        .validateTLSCertificates(false)
                        .userAgent(useragent);
                Log.d(mainActivity.TAG,"getZeakdata:Start");
                Connection.Response response3 = connection3.execute();
                Log.d(mainActivity.TAG,"getZeakdata:statuscode:"+ String.valueOf(response3.statusCode()));
                // Получили json из сервиса
                if (debug) {
                    Log.d(mainActivity.TAG,"getZeakdata:body:"+ response3.body());
                }


                if (debug) {
                    for (Map.Entry<String, String> cookie : response3.cookies().entrySet()) {
                        Log.d(mainActivity.TAG,"cookie2"+ cookie.getKey() + " : " + cookie.getValue());

                    }
                    for (Map.Entry<String, String> head : response3.headers().entrySet()) {
                        Log.d(mainActivity.TAG,"headers2"+ head.getKey() + " : " + head.getValue());
                    }
                }


                dd = response3.parse();
                Log.d(mainActivity.TAG,"getZeakdata:END!");

            } catch (Exception e) {
                e.printStackTrace();
            }
            return dd;
        }
 
開發者ID:alex-yegorkin,項目名稱:zeak.android,代碼行數:41,代碼來源:ZeakSSLConnect.java

示例10: getZeakdata

import org.jsoup.Connection; //導入方法依賴的package包/類
private Document getZeakdata(String getURL) {

            Document dd = null;

            try {
                Connection connection3 = HttpConnection.connect(getURL)
                        .cookies(cooca)
                        .ignoreHttpErrors(true)
                        .ignoreContentType(true)
                        .userAgent(useragent);
                Log.d("getZeakdata:", "Start");
                Connection.Response response3 = connection3.execute();

                // Получили json из сервиса
                if (debug) {
                    Log.d("getZeakdata:body:", response3.body());
                }


                if (debug) {
                    for (Map.Entry<String, String> cookie : response3.cookies().entrySet()) {
                        Log.d("cookie2", cookie.getKey() + " : " + cookie.getValue());

                    }
                    for (Map.Entry<String, String> head : response3.headers().entrySet()) {
                        Log.d("headers2", head.getKey() + " : " + head.getValue());
                    }
                }


                dd = response3.parse();
                Log.d("getZeakdata:", "END!");

            } catch (Exception e) {
                e.printStackTrace();
            }
            return dd;
        }
 
開發者ID:alex-yegorkin,項目名稱:zeak.android,代碼行數:39,代碼來源:ZeakPlainConnect.java

示例11: doInBackground

import org.jsoup.Connection; //導入方法依賴的package包/類
@Override
protected List<Giveaway> doInBackground(Void... params) {
    Log.d(TAG, "Fetching giveaways for user " + path + " on page " + page);

    try {
        // Fetch the Giveaway page
        Connection connection = Jsoup.connect("https://www.steamgifts.com/user/" + path + "/search")
                .userAgent(Constants.JSOUP_USER_AGENT)
                .timeout(Constants.JSOUP_TIMEOUT);
        connection.data("page", Integer.toString(page));
        if (SteamGiftsUserData.getCurrent(fragment.getContext()).isLoggedIn()) {
            connection.cookie("PHPSESSID", SteamGiftsUserData.getCurrent(fragment.getContext()).getSessionId());
            connection.followRedirects(false);
        }

        Connection.Response response = connection.execute();
        Document document = response.parse();

        if (response.statusCode() == 200) {

            SteamGiftsUserData.extract(fragment.getContext(), document);

            if (!user.isLoaded())
                foundXsrfToken = Utils.loadUserProfile(user, document);

            // Parse all rows of giveaways
            return Utils.loadGiveawaysFromList(document);
        } else {
            Log.w(TAG, "Got status code " + response.statusCode());
            return null;
        }
    } catch (Exception e) {
        Log.e(TAG, "Error fetching URL", e);
        return null;
    }
}
 
開發者ID:SteamGifts,項目名稱:SteamGifts,代碼行數:37,代碼來源:LoadUserDetailsTask.java

示例12: ignoresExceptionIfSoConfigured

import org.jsoup.Connection; //導入方法依賴的package包/類
@Test
public void ignoresExceptionIfSoConfigured() throws IOException {
    Connection con = Jsoup.connect("http://direct.infohound.net/tools/404").ignoreHttpErrors(true);
    Connection.Response res = con.execute();
    Document doc = res.parse();
    assertEquals(404, res.statusCode());
    assertEquals("404 Not Found", doc.select("h1").first().text());
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:9,代碼來源:UrlConnectTest.java

示例13: ignores500tExceptionIfSoConfigured

import org.jsoup.Connection; //導入方法依賴的package包/類
@Test
public void ignores500tExceptionIfSoConfigured() throws IOException {
    Connection con = Jsoup.connect("http://direct.infohound.net/tools/500.pl").ignoreHttpErrors(true);
    Connection.Response res = con.execute();
    Document doc = res.parse();
    assertEquals(500, res.statusCode());
    assertEquals("Application Error", res.statusMessage());
    assertEquals("Woops", doc.select("h1").first().text());
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:10,代碼來源:UrlConnectTest.java

示例14: ignores500NoWithContentExceptionIfSoConfigured

import org.jsoup.Connection; //導入方法依賴的package包/類
@Test
public void ignores500NoWithContentExceptionIfSoConfigured() throws IOException {
    Connection con = Jsoup.connect("http://direct.infohound.net/tools/500-no-content.pl").ignoreHttpErrors(true);
    Connection.Response res = con.execute();
    Document doc = res.parse();
    assertEquals(500, res.statusCode());
    assertEquals("Application Error", res.statusMessage());
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:9,代碼來源:UrlConnectTest.java

示例15: doesntRedirectIfSoConfigured

import org.jsoup.Connection; //導入方法依賴的package包/類
@Test
public void doesntRedirectIfSoConfigured() throws IOException {
    Connection con = Jsoup.connect("http://direct.infohound.net/tools/302.pl").followRedirects(false);
    Connection.Response res = con.execute();
    assertEquals(302, res.statusCode());
    assertEquals("https://jsoup.org", res.header("Location"));
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:8,代碼來源:UrlConnectTest.java


注:本文中的org.jsoup.Connection.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。