org.jsoup.Connection.cookies()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(235)

本文整理了Java中org.jsoup.Connection.cookies()方法的一些代码示例,展示了Connection.cookies()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.cookies()方法的具体详情如下:
包路径:org.jsoup.Connection
类名称:Connection
方法名:cookies

Connection.cookies介绍

[英]Adds each of the supplied cookies to the request.
[中]将提供的每个cookie添加到请求中。

代码示例

代码示例来源:origin: RipMeApp/ripme

public Http cookies(Map<String,String> cookies) {
  connection.cookies(cookies);
  return this;
}
public Http data(Map<String,String> data) {

代码示例来源:origin: RipMeApp/ripme

private JSONArray getPageUrls() {
  String postURL = "http://www.tsumino.com/Read/Load";
  try {
    // This sessionId will expire and need to be replaced
    cookies.put("ASP.NET_SessionId","c4rbzccf0dvy3e0cloolmlkq");
    Document doc = Jsoup.connect(postURL).data("q", getAlbumID()).userAgent(USER_AGENT).cookies(cookies).referrer("http://www.tsumino.com/Read/View/" + getAlbumID()).get();
    String jsonInfo = doc.html().replaceAll("<html>","").replaceAll("<head></head>", "").replaceAll("<body>", "").replaceAll("</body>", "")
        .replaceAll("</html>", "").replaceAll("\n", "");
    JSONObject json = new JSONObject(jsonInfo);
    return json.getJSONArray("reader_page_urls");
  } catch (IOException e) {
    LOGGER.info(e);
    sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_ERRORED, "Unable to download album, please compete the captcha at http://www.tsumino.com/Read/Auth/"
        + getAlbumID() + " and try again");
    return null;
  }
}

代码示例来源:origin: RipMeApp/ripme

private String getImageLinkFromDLLink(String url) {
  try {
    Connection.Response response = Jsoup.connect(url)
        .userAgent(USER_AGENT)
        .timeout(10000)
        .cookies(cookies)
        .followRedirects(false)
        .execute();
    String imageURL = response.header("Location");
    LOGGER.info(imageURL);
    return imageURL;
    } catch (IOException e) {
      LOGGER.info("Got error message " + e.getMessage() + " trying to download " + url);
      return null;
    }
}

代码示例来源:origin: YuanKJ-/JsCrawler

@Override
protected void processCookie(RequestModel model) {
  if(model.getCookies() != null) {
    connection.cookies(model.getCookies());
  }
}

代码示例来源:origin: bluetata/crawler-jsoup-maven

.cookies(mapLoginPageCookies)
.timeout(30000)
.get();

代码示例来源:origin: bluetata/crawler-jsoup-maven

con2.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0");
Response login = con2.ignoreContentType(true).method(Method.POST).data(datas).cookies(rs.cookies()).execute();

代码示例来源:origin: bluetata/crawler-jsoup-maven

.data(datas).cookies(cookies).referrer("https://registrar-console.centralnic.com/dashboard/login")
.header("host", "registrar-console.centralnic.com")
.execute();

代码示例来源:origin: songxinjianqwe/Chat

.userAgent(USER_AGENT)
    .timeout(10000)
    .cookies(COOKIE)
    .get();
Elements uls = doc.getElementsByClass("pic-col5");
      .userAgent(USER_AGENT)
      .timeout(10000)
      .cookies(COOKIE)
      .get();
  Elements mainphotos = imgDoc.getElementsByClass("mainphoto");

代码示例来源:origin: bluetata/crawler-jsoup-maven

con2.header(USER_AGENT, USER_AGENT_VALUE);
Response login = con2.ignoreContentType(true).followRedirects(true).method(Method.POST).data(datas).cookies(rs.cookies()).execute();

代码示例来源:origin: bluetata/crawler-jsoup-maven

case UtilsConstants.REQUEST_COOKIES:
  conn.cookies(bindData);
  break;
default:

代码示例来源:origin: BeelGroup/Docear-Desktop

Response response = getConnection(BaseURL + "/scholar")
    .data("q", query, "hl" , this.language)
    .cookies(cookies)					
    .execute();
if(this.debuglogging){
        .data("q", query, "hl" , this.language)
        .data(formData)
        .cookies(cookies)					
        .execute();
    if(this.debuglogging){
      URL url = new URL(new URL(BaseURL), bibtexLink.attr("href"));
      response = getConnection(url.toString())                                   
            .cookies(cookies)						           
            .execute();
      if(this.debuglogging){

代码示例来源:origin: dimtion/Shaarlier

/**
 * Helper method which create a new connection to Shaarli
 * @param url the url of the shaarli
 * @param isPost true if we create a POST request, false for a GET request
 * @return pre-made jsoupConnection
 */
private Connection createShaarliConnection(String url, boolean isPost){
  Connection jsoupConnection = Jsoup.connect(url);
  Connection.Method connectionMethod = isPost ? Connection.Method.POST : Connection.Method.GET;
  if (!"".equals(this.mBasicAuth)) {
    jsoupConnection = jsoupConnection.header("Authorization", "Basic " + this.mBasicAuth);
  }
  if (this.mCookies != null){
    jsoupConnection = jsoupConnection.cookies(this.mCookies);
  }
  return jsoupConnection
      .validateTLSCertificates(this.mValidateCert)
      .timeout(this.mTimeout)
      .followRedirects(true)
      .method(connectionMethod);
}

代码示例来源:origin: BeelGroup/Docear-Desktop

.ignoreHttpErrors(true)
.referrer(e.getUrl())
.cookies(imgCookie)
.followRedirects(false)
.execute();
.ignoreHttpErrors(true)
.referrer(e.getUrl())
.cookies(cookies)
.followRedirects(false)
.execute();

代码示例来源:origin: bluetata/crawler-jsoup-maven

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", "dietime1943@hotmail.com", "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();
  }
}

代码示例来源:origin: io.github.christian-draeger/page-content-tester

connection.cookies(params.getCookie());

代码示例来源:origin: xuxueli/xxl-crawler

conn.cookies(pageRequest.getCookieMap());

代码示例来源:origin: xuxueli/xxl-crawler

conn.cookies(pageRequest.getCookieMap());

代码示例来源:origin: bluetata/crawler-jsoup-maven

.referrer("https://www.oschina.net/home/login")
    .data("username", "dietime1943@hotmail.com", "password", "lvmeng152300").data("save_login", "1")
    .timeout(30 * 1000).cookies(loginForm.cookies()).method(Method.POST).execute();
Document doc = res.parse();
System.out.println(doc);

相关文章