本文整理汇总了Java中org.jsoup.Connection.Method.GET属性的典型用法代码示例。如果您正苦于以下问题:Java Method.GET属性的具体用法?Java Method.GET怎么用?Java Method.GET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jsoup.Connection.Method
的用法示例。
在下文中一共展示了Method.GET属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUrlResult
/**
* 根据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();
}
}
示例2: loadUrl
private Document loadUrl(String pUrl) throws IOException {
Method method = Method.GET;
if (LOG.isTraceEnabled()) {
LOG.trace("----------------------");
LOG.trace("Emitter.loadUrl() started");
}
Document newDocument = loadOrCache(pUrl, method);
if (LOG.isTraceEnabled()) {
LOG.trace("Emitter.loadUrl() complete");
LOG.trace("----------------------");
}
return newDocument;
}
示例3: connectReuse
/**
* @desc 进行实际的链接
* @date 2015年8月17日-下午4:54:23
* @param url
* @param referrer
* @param postDataCharset
* @param isPost
* @param dataMap
* @param proxyIp
* @param proxyPort
* @return Response
*/
@Override
public Connection connectReuse(Connection lastCon,String url,String referrer,String postDataCharset,boolean isPost,Map dataMap,String dataString,
String proxyIp,int proxyPort){
try{
Method method= null;
if(isPost){
method = Method.POST;
}else{
method = Method.GET;
}
Connection connect = null;
if(lastCon==null){
connect = Jsoup.connect(url);
}else{
connect = lastCon.url(url);
}
connect = connect
.userAgent(config.getString("common.http.user.agent",DEFAULT_USER_AGENT))
.timeout(config.getInt("common.http.timeout.ms",DEFAULT_TIMEOUT))
.followRedirects(true)
.referrer(referrer)
.postDataCharset(postDataCharset)
.validateTLSCertificates(false)
.ignoreContentType(true)
.method(method);
if(dataMap!=null && dataMap.size()>0){
connect = connect.data(dataMap);
}
if(StringUtils.isNotBlank(dataString)){
connect = connect.requestBody(dataString);
}
if(StringUtils.isNotBlank(proxyIp) && proxyPort > 0) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyIp, proxyPort));
connect = connect.proxy(proxy);
}
return connect;
} catch (Exception e) {
logger.error("connectImpl():exception:url:"+url+" referrer:"+referrer+
" postDataCharset:"+postDataCharset+ " isPost:"+isPost+
" dataMap:"+dataMap+" e:"+e.getMessage(),e);
return null;
}
}