本文整理了Java中org.jsoup.Connection.post()
方法的一些代码示例,展示了Connection.post()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.post()
方法的具体详情如下:
包路径:org.jsoup.Connection
类名称:Connection
方法名:post
[英]Execute the request as a POST, and parse the result.
[中]将请求作为POST执行,并解析结果。
代码示例来源:origin: RipMeApp/ripme
.timeout(5000)
.data(postData)
.post();
String jsonString = doc.toString();
jsonString = jsonString.substring(jsonString.indexOf("<!json>") + "<!json>".length());
代码示例来源:origin: pl.edu.icm.polindex/polindex-core
public Document postQuery(String url, Map<String,String> parameters, int timeoutMillis) throws IOException {
Preconditions.checkArgument(StringUtils.isNotBlank(url));
Date start = new Date();
Connection con = Jsoup.connect(url)
.timeout(timeoutMillis)
.ignoreHttpErrors(false);
if (parameters != null && !parameters.isEmpty()) {
con.data(parameters);
}
logger.info(".. sending POST request to "+url+ " ...");
Document doc = con.post();
Date stop = new Date();
logger.info(".. document from ["+url+"] received & parsed in "+ BeanStats.formatMillisPretty(stop.getTime() - start.getTime(), 0));
return doc;
}
}
代码示例来源:origin: bluetata/crawler-jsoup-maven
/***
* 远程访问URL返回Doc
* @param remoteUrl
* @return
*/
public static Document postRemoteURL(String remoteUrl) {
Document doc = null;
int temp = 0;
try {
temp = Integer.parseInt(Math.round(Math.random()*(UserAgent.length-1))+"");
Connection conn = Jsoup.connect(remoteUrl);
conn.header("User-Agent", UserAgent[temp]);
conn.cookie("auth", "token");
doc = conn.timeout(MAX_CONNECT_TIME).post();
} catch (Exception ex) {
logger.error("GrabUnits.class_postRemoteURL 出现异常...");
logger.error(ex);
}
try {
int sleeptime = Integer.parseInt(Math.round(Math.random()*10000)+"");
logger.info(BrowserType[temp] +" POST请求 " + remoteUrl + " 停留 " + sleeptime + " 毫秒。");
Thread.sleep(sleeptime);
} catch (InterruptedException ex) {
logger.error("GrabUnits.class_postRemoteURL 休眠出现异常...");
logger.error(ex);
}
return doc;
}
代码示例来源:origin: net.minidev/ovh-java-sdk-core
/**
* Create a new OVH Application using https://eu.api.ovh.com/createApp/
* Outout the Application Key and Application Secret in std-out
* @param nic
* @param password
* @throws IOException
*/
public void createApplication(String nic, String password) throws IOException {
String url = "https://eu.api.ovh.com/createApp/";
Document doc = Jsoup.connect(url)
.data("nic", nic)
.data("password", password)
.data("applicationName", "One Shoot Token")
.data("applicationDescription", "One Shoot Token")
.post();
String body = doc.toString();
Pattern extract = Pattern.compile(" Application (\\w+)<pre><name>([^<]+)</name></pre>");
Matcher m = extract.matcher(body);
String Key = null;
String Secret = null;
while (m.find()) {
String k = m.group(1);
String v = m.group(2);
if (k.equals("Key"))
Key = v;
if (k.equals("Secret"))
Secret = v;
}
log.warn("Key:{} Secret:{}", Key, Secret);
}
代码示例来源:origin: SudaVideo/MyVideoApi
.header("Referer", playerUrl)
.data(map)
.post();
try {
JSONObject jsonObject = JSONObject.parseObject(document.body().text());
代码示例来源:origin: Patreon/patreon-java
public TokensResponse refreshTokens(String refreshToken) throws IOException {
Connection requestInfo = Jsoup.connect(PatreonAPI.BASE_URI + "/api/oauth2/token")
.data("grant_type", GRANT_TYPE_TOKEN_REFRESH)
.data("client_id", clientID)
.data("client_secret", clientSecret)
.data("refresh_token", refreshToken)
.ignoreContentType(true);
String response = requestInfo.post().body().text();
return toObject(response, TokensResponse.class);
}
代码示例来源:origin: net.minidev/ovh-java-sdk-core
Document doc2 = validForm.post();
Elements p = doc2.select("p");
String pText = p.text();
代码示例来源:origin: Patreon/patreon-java
public TokensResponse getTokens(String code) throws IOException {
Connection requestInfo = Jsoup.connect(PatreonAPI.BASE_URI + "/api/oauth2/token")
.data("grant_type", GRANT_TYPE_AUTHORIZATION)
.data("code", code)
.data("client_id", clientID)
.data("client_secret", clientSecret)
.data("redirect_uri", redirectUri)
.ignoreContentType(true);
String response = requestInfo.post().body().text();
return toObject(response, TokensResponse.class);
}
代码示例来源:origin: Vegen/SmartCampus
connection.data("Date", "30");
connection.data("tags", "");
Document document = connection.post();
e.onNext(document);
e.onComplete();
代码示例来源: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: xuxueli/xxl-crawler
html = conn.post();
} else {
html = conn.get();
代码示例来源:origin: yy1193889747/springboot-demo
Document post = Jsoup.connect("").data(data).post();
Document post1 = Jsoup.connect("").data("","").method(Connection.Method.POST).execute().parse();
Document post2 = Jsoup.connect("").requestBody(jsonObject.toString()).post();
内容来源于网络,如有侵权,请联系作者删除!