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


Java HttpConnection.connect方法代码示例

本文整理汇总了Java中org.jsoup.helper.HttpConnection.connect方法的典型用法代码示例。如果您正苦于以下问题:Java HttpConnection.connect方法的具体用法?Java HttpConnection.connect怎么用?Java HttpConnection.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jsoup.helper.HttpConnection的用法示例。


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

示例1: connect

import org.jsoup.helper.HttpConnection; //导入方法依赖的package包/类
/**
 * Creates a new {@link Connection} to a URL. Use to fetch and parse a HTML page.
 * <p>
 * Use examples:
 * <ul>
 *  <li><code>Document doc = Jsoup.connect("http://example.com").userAgent("Mozilla").data("name", "jsoup").get();</code></li>
 *  <li><code>Document doc = Jsoup.connect("http://example.com").cookie("auth", "token").post();</code></li>
 * </ul>
 * @param url URL to connect to. The protocol must be {@code http} or {@code https}.
 * @return the connection. You can add data, cookies, and headers; set the user-agent, referrer, method; and then execute.
 */
public static Connection connect(String url) {
    return HttpConnection.connect(url);
}
 
开发者ID:cpusoft,项目名称:common,代码行数:15,代码来源:Jsoup.java

示例2: connect

import org.jsoup.helper.HttpConnection; //导入方法依赖的package包/类
/**
 * Creates a new {@link Connection} to a URL. Use to fetch and parse a HTML page.
 * <p>
 * Use examples:
 * <ul>
 *  <li><code>Document doc = Jsoup.connect("http://example.com").userAgent("Mozilla").data("name", "jsoup").get();</code></li>
 *  <li><code>Document doc = Jsoup.connect("http://example.com").cookie("auth", "token").post();
 * </ul>
 * @param url URL to connect to. The protocol must be {@code http} or {@code https}.
 * @return the connection. You can add data, cookies, and headers; set the user-agent, referrer, method; and then execute.
 */
public static Connection connect(String url) {
    return HttpConnection.connect(url);
}
 
开发者ID:gumulka,项目名称:JabRefAutocomplete,代码行数:15,代码来源:Jsoup.java

示例3: fetch

import org.jsoup.helper.HttpConnection; //导入方法依赖的package包/类
/**
 Fetch a URL, and parse it as HTML. Provided for compatibility; in most cases use {@link #connect(String)} instead.
 <p>
 The encoding character set is determined by the content-type header or http-equiv meta tag, or falls back to {@code UTF-8}.

 @param url           URL to fetch (with a GET). The protocol must be {@code http} or {@code https}.
 @param timeoutMillis Connection and read timeout, in milliseconds. If exceeded, IOException is thrown.
 @return The parsed HTML.

 @throws java.net.MalformedURLException if the request URL is not a HTTP or HTTPS URL, or is otherwise malformed
 @throws HttpStatusException if the response is not OK and HTTP response errors are not ignored
 @throws UnsupportedMimeTypeException if the response mime type is not supported and those errors are not ignored
 @throws java.net.SocketTimeoutException if the connection times out
 @throws IOException if a connection or read error occurs

 @see #connect(String)
 */
public static Document parse(URL url, int timeoutMillis) throws IOException {
    Connection con = HttpConnection.connect(url);
    con.timeout(timeoutMillis);
    return con.get();
}
 
开发者ID:cpusoft,项目名称:common,代码行数:23,代码来源:Jsoup.java

示例4: fetch

import org.jsoup.helper.HttpConnection; //导入方法依赖的package包/类
/**
 Fetch a URL, and parse it as HTML. Provided for compatibility; in most cases use {@link #connect(String)} instead.
 <p>
 The encoding character set is determined by the content-type header or http-equiv meta tag, or falls back to {@code UTF-8}.

 @param url           URL to fetch (with a GET). The protocol must be {@code http} or {@code https}.
 @param timeoutMillis Connection and read timeout, in milliseconds. If exceeded, IOException is thrown.
 @return The parsed HTML.

 @throws IOException If the final server response != 200 OK (redirects are followed), or if there's an error reading
 the response stream.

 @see #connect(String)
 */
public static Document parse(URL url, int timeoutMillis) throws IOException {
    Connection con = HttpConnection.connect(url);
    con.timeout(timeoutMillis);
    return con.get();
}
 
开发者ID:gumulka,项目名称:JabRefAutocomplete,代码行数:20,代码来源:Jsoup.java


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