当前位置: 首页>>代码示例>>Java>>正文


Java Method类代码示例

本文整理汇总了Java中org.jsoup.Connection.Method的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Method类属于org.jsoup.Connection包,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import org.jsoup.Connection.Method; //导入依赖的package包/类
private void login() throws IOException {
    Response resp = Http.url(this.url).response();
    cookies = resp.cookies();
    String ctoken = resp.parse().select("form > input[name=ctoken]").first().attr("value");

    Map<String,String> postdata = new HashMap<>();
    postdata.put("user[login]", new String(Base64.decode("cmlwbWU=")));
    postdata.put("user[password]", new String(Base64.decode("cmlwcGVy")));
    postdata.put("rememberme", "1");
    postdata.put("ctoken", ctoken);

    resp = Http.url("http://en.2dgalleries.com/account/login")
               .referrer("http://en.2dgalleries.com/")
               .cookies(cookies)
               .data(postdata)
               .method(Method.POST)
               .response();
    cookies = resp.cookies();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:20,代码来源:TwodgalleriesRipper.java

示例2: signinToFlickr

import org.jsoup.Connection.Method; //导入依赖的package包/类
/**
 * Login to Flickr.
 * @return Cookies for logged-in session
 * @throws IOException
 */
@SuppressWarnings("unused")
private Map<String,String> signinToFlickr() throws IOException {
    Response resp = Jsoup.connect("http://www.flickr.com/signin/")
                        .userAgent(USER_AGENT)
                        .followRedirects(true)
                        .method(Method.GET)
                        .execute();
    Document doc = resp.parse();
    Map<String,String> postData = new HashMap<>();
    for (Element input : doc.select("input[type=hidden]")) {
        postData.put(input.attr("name"),  input.attr("value"));
    }
    postData.put("passwd_raw",  "");
    postData.put(".save",   "");
    postData.put("login",   new String(Base64.decode("bGVmYWtlZGVmYWtl")));
    postData.put("passwd",  new String(Base64.decode("MUZha2V5ZmFrZQ==")));
    String action = doc.select("form[method=post]").get(0).attr("action");
    resp = Jsoup.connect(action)
                .cookies(resp.cookies())
                .data(postData)
                .method(Method.POST)
                .execute();
    return resp.cookies();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:30,代码来源:FlickrRipper.java

示例3: postStatsOn

import org.jsoup.Connection.Method; //导入依赖的package包/类
private static void postStatsOn(String homeUrl, APIKey token, IShard shard) {
	try {
		JSONObject content = new JSONObject()
				.put("shard_id", shard.getInfo()[0])
				.put("shard_count", shard.getInfo()[1])
				.put("server_count", shard.getGuilds().size());

		Map<String, String> header = new HashMap<>();
		header.put("Content-Type", "application/json");
		header.put("Authorization", APIKeys.get(token));

		String url = String.format("%s/api/bots/%d/stats", homeUrl, shard.getClient().getOurUser().getLongID());
		Jsoup.connect(url)
				.method(Method.POST)
				.ignoreContentType(true)
				.headers(header)
				.requestBody(content.toString())
				.post();
	} catch (Exception err) {
		LogUtils.infof("An error occurred while posting statistics of shard %d. (%s: %s).",
				shard.getInfo()[0], err.getClass().getSimpleName(), err.getMessage());
	}
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:24,代码来源:NetUtils.java

示例4: getNewVersion

import org.jsoup.Connection.Method; //导入依赖的package包/类
public static Map<String, String> getNewVersion() throws IOException,
		JSONException {
	Connection.Response response = Jsoup
			.connect(MyStringUtils.CURL + MyStringUtils.API_TAKEN)
			.method(Method.GET).ignoreContentType(true).timeout(5000)
			.execute();
	JSONObject dataJson = new JSONObject(response.body());
	JSONObject dataJson2 = dataJson.getJSONObject("binary");
	map.put("name", dataJson.getString("name"));
	map.put("version", dataJson.getString("version"));
	map.put("changelog", dataJson.getString("changelog"));
	map.put("versionShort", dataJson.getString("versionShort"));
	map.put("direct_install_url", dataJson.getString("direct_install_url"));
	map.put("fsize", bytes2kb(Long.parseLong(dataJson2.getString("fsize"))));
	return map;
}
 
开发者ID:shenhuanet,项目名称:Account-android,代码行数:17,代码来源:CheckUpdate.java

示例5: authentificationKi

import org.jsoup.Connection.Method; //导入依赖的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

示例6: connectDns

import org.jsoup.Connection.Method; //导入依赖的package包/类
@Test
public void connectDns() throws IOException{
    Map m2 = new HashMap();
    m2.put("grant_type", "password");
    m2.put("username", "test");
    m2.put("password", "12345");

    Map m = new HashMap();
    m.put("resource_type","token_gen_cmd");
    m.put("attrs", m2);

    HttpForm httpForm = HttpForm.gene().
            setUrl("https://1.1.1.1/auth_cmd").
            setReferrer("https://1.1.1.1").
            setMethod(Method.POST).
            setDataString(JsonUtil.Object2JsonString(m));

    String r = httpService.simpleConnect(httpForm );
    System.out.println(r);

}
 
开发者ID:cpusoft,项目名称:common,代码行数:22,代码来源:HttpServiceTest.java

示例7: getGroupList_old

import org.jsoup.Connection.Method; //导入依赖的package包/类
/**
 * 获取群列表
 * url : http://qun.qq.com/cgi-bin/qun_mgr/get_group_list
 * method : post
 * parameters : bkn
 * getGroupList 方法
 */
@Deprecated
public static List<GroupListVO> getGroupList_old(){
	try {
		List<GroupListVO> list = new ArrayList<>();
		Map<String, String> data = new HashMap<>();
		data.put("bkn", getCsrfToken());
		Map<String, String> cookies = getCookies();
		String result = WebUtil.fetch("http://qun.qq.com/cgi-bin/qun_mgr/get_group_list", Method.POST, data, cookies);
		if(result != null){
			//System.out.println(result);
			JSONArray jarr = JSONObject.parseObject(result).getJSONArray("manage");
			GroupListVO listVO = null;
			for(int a=0; a<jarr.size(); a++){
				JSONObject obj = jarr.getJSONObject(a);
				listVO = new GroupListVO(obj.getLong("gc"), obj.getString("gn"), obj.getLong("owner"));
				list.add(listVO);
			}
			return list;
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return null;
}
 
开发者ID:ForeverWJY,项目名称:CoolQ_Java_Plugin,代码行数:32,代码来源:CQSDK.java

示例8: getGroupMemberList2

import org.jsoup.Connection.Method; //导入依赖的package包/类
/**
 * 获取群成员列表方法2
 * url : http://qun.qzone.qq.com/cgi-bin/get_group_member?uin=1066231345&groupid=215400054&random=0.15297316415049034&g_tk=277066193
 * mehod : get
 * parameters :
 * 	uin = QQ号
 *  groupid = 群号
 *  random = 随机数
 *  g_tk = csrtoken
 */
@Deprecated
public static List<GroupMemberListVO> getGroupMemberList2(String group){
	try {
		List<GroupMemberListVO> voList = new ArrayList<>();
		Map<String, String> cookies = getCookies();
		String url = "http://qun.qzone.qq.com/cgi-bin/get_group_member?uin="+getLoginQQ()
		+"&groupid="+group+"&random="+Math.random()+"&g_tk="+getCsrfToken();
		System.out.println(url);
		Map<String, String> data = new HashMap<>(0);
		String result = WebUtil.fetch(url, Method.GET, data, cookies);
		if(result != null){
			result = result.substring(10, result.length() - 2);
			JSONArray jarr = JSONObject.parseObject(result).getJSONObject("data").getJSONArray("item");
			for(int i=0; i<jarr.size(); i++){
				JSONObject obj = jarr.getJSONObject(i);
				voList.add(new GroupMemberListVO(obj.getString("nick"), obj.getLong("uin"), obj.getInteger("iscreator"), obj.getInteger("ismanager")));
			}
			return voList;
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return null;
}
 
开发者ID:ForeverWJY,项目名称:CoolQ_Java_Plugin,代码行数:35,代码来源:CQSDK.java

示例9: getUrlResult

import org.jsoup.Connection.Method; //导入依赖的package包/类
/**
 * 根据URL和请求类型获取请求结果,用于跨域请求
 * @param url
 * @param urlType POST OR GET
 * @return
 */
public static String getUrlResult(String url,String urlType){
	Method method = null;
	if(urlType!= null && !"".equals(urlType) && urlType.equalsIgnoreCase("post")){
		method = Method.POST;
	}else{
		method = Method.GET;
	}
	Response resp = null;
	try {
		resp = Jsoup.connect(url).userAgent("Chrome").timeout(5000).ignoreContentType(true).method(method).execute();
	} catch (IOException e) {
		log.error(WebUtil.class,e);
	}
	if(resp == null){
		return "error";
	}else{
		return resp.body();
	}
}
 
开发者ID:ForeverWJY,项目名称:CoolQ_Java_Plugin,代码行数:26,代码来源:WebUtil.java

示例10: extract

import org.jsoup.Connection.Method; //导入依赖的package包/类
public BibtexEntry extract(String url) {
	try {
		Document doc = Jsoup.connect(url).get();
		Element form = doc.select("form[name=exportCite]").first();
		Connection con = Jsoup.connect("http://www.sciencedirect.com" + form.attr("action"));
		for(Element hidden : form.select("input[type=hidden]"))
			con.data(hidden.attr("name"), hidden.attr("value"));
		con.data("zone", "exportDropDown");
		con.data("citation-type", "BIBTEX");
		con.data("format", "cite-abs");
		con.data("export", "Export");
		con.method(Method.POST);
		Response res = con.execute();
		return BibtexParser.singleFromString(res.body());
	} catch (Exception e) {
		Log.error(e, "Error extracting the url: " + url);
	}
	return null;
}
 
开发者ID:gumulka,项目名称:JabRefAutocomplete,代码行数:20,代码来源:ScienceDirect.java

示例11: extract

import org.jsoup.Connection.Method; //导入依赖的package包/类
public BibtexEntry extract(String url) {
	try {
		Connection con = Jsoup.connect("http://ieeexplore.ieee.org/xpl/downloadCitations");
		String id = url.substring(url.indexOf("arnumber=")+9);
		int index = id.indexOf('&');
		if(index>0)
			id = id.substring(0, index);
		con.data("recordIds", id);
		con.data("citations-format","citation-abstract");
		con.data("download-format", "download-bibtex");
		con.method(Method.POST);
		Response res = con.execute();
		return BibtexParser.singleFromString(res.body().replace("<br>", ""));
	} catch (Exception e) {
		Log.error(e, "Error extracting the url: " + url);
	}
	return null;
}
 
开发者ID:gumulka,项目名称:JabRefAutocomplete,代码行数:19,代码来源:IEEE.java

示例12: login

import org.jsoup.Connection.Method; //导入依赖的package包/类
/**
 * <code>
 * Login to a website. Find the login URL from the action element of the form that
 * is used on the login page of that website.
 * Typically it's best to use the Chrome nework inspector to copy all of the form values
 * that are submitted.  This is especially important when you're talking to a .NET application
 * as they have crazy viewstate parameters that need to be sent.
 * </code>
 *
 * @param pUrl
 *            The URL to submit the login to.
 * @param pKeyValues
 *            A splat of key value pairs that will be submitted as part of
 *            the login
 */
public void login(String pUrl, String... pKeyValues) throws IOException {
    if (LOG.isTraceEnabled()) {
        LOG.trace("----------------------");
        LOG.trace("Emitter.login() started");
    }
    if (noLoginCache) {
        LOG.info("Logging in to: " + pUrl);
        loadRaw(pUrl, Method.POST, pKeyValues);
    } else {
        loadOrCache(pUrl, Method.POST, pKeyValues);
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("Emitter.login() complete");
        LOG.trace("----------------------");
    }
}
 
开发者ID:groupby,项目名称:scrapie,代码行数:32,代码来源:Emitter.java

示例13: loadRaw

import org.jsoup.Connection.Method; //导入依赖的package包/类
private Document loadRaw(String pUrl, Method method, String... pKeyValues)
        throws IOException {
    Document newDocument;
    String cacheDir2 = createCacheDir();
    File hashFile2 = new File(cacheDir2
            + DigestUtils.md5Hex(extractSaliantParts(pUrl))
            + describe(pUrl) + ".html");
    ensureCacheDirExists(cacheDir2);
    Connection connection = createConnection(pUrl);
    connection.data(pKeyValues);
    Connection.Response res = execute(method, connection);
    cookies.putAll(res.cookies());
    printCookies("Receiving", res.cookies());
    newDocument = res.parse();
    final String body = res.body();
    if (!containsInvalidCacheContent(body)) {
        FileUtils.write(hashFile2, body, "UTF8");
    }
    return newDocument;
}
 
开发者ID:groupby,项目名称:scrapie,代码行数:21,代码来源:Emitter.java

示例14: execute

import org.jsoup.Connection.Method; //导入依赖的package包/类
private Connection.Response execute(Method method, Connection connection) throws IOException {
    int requestAttempts = 0;
    while (true) {
        try {
            return connection.method(method).execute();
        } catch (IOException e) {
            if (requestAttempts >= 3) {
                throw new IOException("Tried connection three times with " +
                        waitTimes[0] +
                        " second, " +
                        waitTimes[1] +
                        " second and " +
                        waitTimes[2] +
                        " second waits.", e);
            }
            LOG.warn("Got exception " + requestAttempts + " pausing for " + waitTimes[requestAttempts] + " second(s).  Exception was " + e.getMessage());
            sleepSeconds(waitTimes[requestAttempts]);
            requestAttempts++;
        }
    }
}
 
开发者ID:groupby,项目名称:scrapie,代码行数:22,代码来源:Emitter.java

示例15: doInBackground

import org.jsoup.Connection.Method; //导入依赖的package包/类
protected Document doInBackground(String... urls) {
    Log.d(LOG_TAG, "doInBackground, url=" + urls[0]);
    try {
        Response resp = Jsoup.connect(urls[0])
                .header("Authorization", "Basic " + base64login).timeout(30 * 1000)
                .method(Method.GET).execute();
        if (resp.contentType().contains("text/html")) {
            Log.d(LOG_TAG, "New directory");
            currentUrl = urls[0];
            return resp.parse();
        } else {
            Log.d(LOG_TAG, "UnsupportedContentType");
            return null;
        }
    } catch (UnsupportedMimeTypeException me) {
        Log.d(LOG_TAG, "UnsupportedMimeTypeException");
        return null;
    } catch (Exception e) {
        Log.d(LOG_TAG, "Other Exception");
        this.exception = e;
        return null;
    }
}
 
开发者ID:qiushengxy,项目名称:cast-any,代码行数:24,代码来源:HttpActivity.java


注:本文中的org.jsoup.Connection.Method类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。