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

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

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

Connection.referrer介绍

[英]Set the request referrer (aka "referer") header.
[中]设置请求referer(又名“referer”)头。

代码示例

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

public Http referrer(String ref)  {
  connection.referrer(ref);
  return this;
}
public Http referrer(URL ref) {

代码示例来源: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: ahmetaa/zemberek-nlp

.userAgent(
    "Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
  .referrer("http://www.google.com")
  .get();
doc = doc.normalise();

代码示例来源:origin: skydoves/SyncMarket

private static Elements getElementsFromNetwork(final String selects) {
  try {
    Elements elements = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName)
        .timeout(timeout)
        .ignoreHttpErrors(true)
        .referrer("http://www.google.com").get()
        .select(selects);
    if(elements.size() != 0)
      return elements;
  } catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: skydoves/SyncMarket

private static String getAttrFromNetwork(final String selects) {
  String result = "none";
  try {
    Elements elements = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName)
        .timeout(timeout)
        .ignoreHttpErrors(true)
        .referrer("http://www.google.com").get()
        .select(selects);
    if(elements.size() != 0)
      result = elements.first().ownText();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return result;
}

代码示例来源:origin: robohorse/gpversionchecker

private Version obtainDataFromGooglePlayWithException(boolean englishLanguage, String currentVersion)
      throws IOException, NumberFormatException {

    final Context context = getApplicationContext();
    final String packageName = context.getPackageName();
    final String language = englishLanguage ? Locale.ENGLISH.getLanguage() : Locale.getDefault().getLanguage();

    final String url = context.getString(R.string.gpvch_google_play_url) + packageName + "&hl=" + language;
    ALog.d("request params: package - " + packageName + ", current app version: " + currentVersion);

    final Document document = Jsoup.connect(url)
        .timeout(CONNECTION_TIMEOUT)
        .userAgent(USER_AGENT)
        .referrer(REFERRER)
        .get();
    return new DataParser().parse(document, url);
  }
}

代码示例来源: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: BeelGroup/Docear-Desktop

protected Connection getConnection(String URL) {		
  return Jsoup.connect(URL)				   
        .ignoreContentType(true)
        .userAgent(this.userAgent)  
        .referrer(this.referrer)   
        .timeout(this.timeout) 
        .followRedirects(this.followRedirects);		           
}

代码示例来源:origin: Kaysoro/KaellyBot

public static Connection.Response getResponse(String url) throws IOException {
    return Jsoup.connect(url)
        .userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0")
        .referrer("http://www.google.com")
        .timeout(10000)
        .validateTLSCertificates(false)
        .execute();
  }
}

代码示例来源:origin: Kaysoro/KaellyBot

public static Document getDocument(String url) throws IOException {
  return Jsoup.connect(url)
      .userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0")
      .referrer("http://www.google.com")
      .timeout(10000)
      .validateTLSCertificates(false)
      .get();
}

代码示例来源:origin: jrvansuita/CheckNewAppVersionAvailable

@Override
protected Result doInBackground(Void... params) {
  try {
    //Getting the current versions of the app and setting as old version is Result object.
    PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    result.setOldVersionCode(info.versionName);
  } catch (PackageManager.NameNotFoundException e) {
    //Handle this exception by your own way...
  }
  try {
    //Using the Jsoup library to request the store app page and getting the app version code.
    String newVersion = Jsoup.connect(getExternalAppLink())
        .timeout(30000)
        .userAgent(USER_AGENT)
        .referrer(REFERRER)
        .get()
        .select(DIV)
        .first()
        .ownText();
    result.setNewVersionCode(newVersion);
  } catch (Exception e) {
    //Handle this exception by your own way...
  }
  return result;
}

代码示例来源:origin: malmstein/yahnac

public Connection loginConnection(String username, String password) {
  Connection login = connection(LOGIN_BASE_URL);
  return login
      .data("go_to", "news")
      .data("acct", username)
      .data("pw", password)
      .header("Origin", ConnectionProvider.BASE_URL)
      .followRedirects(true)
      .referrer(ConnectionProvider.BASE_URL + ConnectionProvider.LOGIN_URL_EXTENSION)
      .method(Connection.Method.POST);
}

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

.data(formData)
              .ignoreHttpErrors(true)
              .referrer(e.getUrl())
              .cookies(imgCookie)
              .followRedirects(false)
Response abuseResponse = getConnection(captchaResponse.header("Location"))
              .ignoreHttpErrors(true)
              .referrer(e.getUrl())
              .cookies(cookies)
              .followRedirects(false)

代码示例来源:origin: Kaysoro/KaellyBot

public static Document postDocument(String url, Map<String, String> header, Map<String, String> data) throws IOException {
  return Jsoup.connect(url)
      .userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0")
      .referrer("http://www.google.com")
      .headers(header)
      .data(data)
      .timeout(10000)
      .validateTLSCertificates(false)
      .post();
}

代码示例来源: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

.referrer(params.getReferrer())

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

conn.referrer(pageRequest.getReferrer());

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

conn.referrer(pageRequest.getReferrer());

代码示例来源: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();

相关文章