• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Method类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: doInBackground

import org.jsoup.Connection.Method; //导入依赖的package包/类
protected Document doInBackground(String... urls) {
    try {
        Response resp = Jsoup
                .connect(urls[0])
                .timeout(10 * 1000)
                .cookie("pianhao",
                        "%7B%22qing%22%3A%22super%22%2C%22qtudou%22%3A%22null%22%2C%22qyouku%22%3A%22null%22%2C%22q56%22%3A%22null%22%2C%22qcntv%22%3A%22null%22%2C%22qletv%22%3A%22null%22%2C%22qqiyi%22%3A%22null%22%2C%22qsohu%22%3A%22null%22%2C%22qqq%22%3A%22null%22%2C%22qku6%22%3A%22null%22%2C%22qyinyuetai%22%3A%22null%22%2C%22qtangdou%22%3A%22null%22%2C%22qxunlei%22%3A%22null%22%2C%22qfunshion%22%3A%22null%22%2C%22qsina%22%3A%22null%22%2C%22qpptv%22%3A%22null%22%2C%22xia%22%3A%22ask%22%2C%22pop%22%3A%22no%22%2C%22open%22%3A%22no%22%7D")
                .method(Method.GET).execute();

        return resp.parse();
    } catch (UnsupportedMimeTypeException me) {

        return null;
    } catch (Exception e) {
        this.exception = e;
        return null;
    }
}
 
开发者ID:qiushengxy,项目名称:cast-any,代码行数:19,代码来源:WebActivity.java


示例17: defaultSettings

import org.jsoup.Connection.Method; //导入依赖的package包/类
private void defaultSettings() {
    this.retries = Utils.getConfigInteger("download.retries", 1);
    connection = Jsoup.connect(this.url);
    connection.userAgent(AbstractRipper.USER_AGENT);
    connection.method(Method.GET);
    connection.timeout(TIMEOUT);
    connection.maxBodySize(0);
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:9,代码来源:Http.java


示例18: connect

import org.jsoup.Connection.Method; //导入依赖的package包/类
static Map<String,String> connect() throws IOException{
    Connection.Response res = Jsoup.connect("https://www.facebook.com/login.php")
            .data("username", "[email protected]", "password", "password")
            .timeout(30 * 1000)
            .userAgent("Mozilla/5.0")
            .method(Method.POST)
            .execute();
    Document doc = res.parse();
    System.out.println(doc);
    
    Map<String, String> loginCookies = res.cookies();
    String sessionId = res.cookie("SESSIONID");
    return loginCookies;
}
 
开发者ID:bluetata,项目名称:crawler-jsoup-maven,代码行数:15,代码来源:FacebookLoginApater.java


示例19: main

import org.jsoup.Connection.Method; //导入依赖的package包/类
public static void main(String[] args) throws IOException {

        try {
            String url = "https://www.oschina.net/home/login";
            String userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36";

            Connection.Response response = Jsoup.connect(url).userAgent(userAgent).method(Connection.Method.GET)
                    .execute();

            response = Jsoup.connect(url).cookies(response.cookies()).userAgent(userAgent)
                    .referrer("https://www.oschina.net/home/login?goto_page=https%3A%2F%2Fmy.oschina.net%2Fbluetata")
                    .data("username", "[email protected]", "password", "lvmeng152300").data("save_login", "1")
                    .followRedirects(false)
                    .method(Connection.Method.POST).followRedirects(true).timeout(30 * 1000).execute();

            System.err.println(response.statusCode());
            
            Document doc = Jsoup.connect("https://my.oschina.net/bluetata").cookies(response.cookies())
                    .userAgent(userAgent).timeout(30 * 1000).get();

            System.out.println(doc);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
 
开发者ID:bluetata,项目名称:crawler-jsoup-maven,代码行数:28,代码来源:WeiboCNLoginApater.java


示例20: connect

import org.jsoup.Connection.Method; //导入依赖的package包/类
static Map<String, String> connect() throws IOException {

        // Connection.Response loginForm =
        // Jsoup.connect("https://passport.weibo.cn/signin/login")
        // .method(Connection.Method.GET)
        // .execute();
        //
        // Connection.Response res =
        // Jsoup.connect("https://passport.weibo.cn/signin/login")
        // .data("username", "18241141433", "password", "152300")
        // .data("ec", "0", "entry", "mweibo")
        // .data("mainpageflag", "1", "savestate", "1")
        // .timeout(30 * 1000)
        // .userAgent("Mozilla/5.0")
        // .cookies(loginForm.cookies())
        // .method(Method.POST)
        // .execute();
        // Document doc = res.parse();
        // System.out.println(doc);

        Connection.Response loginForm = Jsoup.connect("https://www.oschina.net/home/login")
                .method(Connection.Method.GET).execute();

        Connection.Response res = Jsoup.connect("https://www.oschina.net/home/login").header("Host", "www.oschina.net")
                .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0")
                .referrer("https://www.oschina.net/home/login")
                .data("username", "[email protected]", "password", "lvmeng152300").data("save_login", "1")
                .timeout(30 * 1000).cookies(loginForm.cookies()).method(Method.POST).execute();
        Document doc = res.parse();
        System.out.println(doc);

        Map<String, String> loginCookies = res.cookies();
        String sessionId = res.cookie("SESSIONID");

        return loginCookies;
    }
 
开发者ID:bluetata,项目名称:crawler-jsoup-maven,代码行数:37,代码来源:WeiboCNLoginApater.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DialogPeer类代码示例发布时间:2022-05-21
下一篇:
Java HdfsBolt类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap