当前位置: 首页>>代码示例>>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;未经允许,请勿转载。