本文整理汇总了Java中org.jsoup.Connection.ignoreContentType方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.ignoreContentType方法的具体用法?Java Connection.ignoreContentType怎么用?Java Connection.ignoreContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.Connection
的用法示例。
在下文中一共展示了Connection.ignoreContentType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchoolNotice
import org.jsoup.Connection; //导入方法依赖的package包/类
/**
* 获取学校通知接口
*
* @param cookiesMap
* @param index
* @return
*/
public static Response getSchoolNotice(Map<String, String> cookiesMap, int index) {
try {
Connection con = Jsoup.connect(Constant.SchoolNotice.URL);
con.ignoreContentType(true);
Iterator<Map.Entry<String, String>> it = cookiesMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> en = it.next();
con = con.cookie(en.getKey(), en.getValue());
}
return con.method(Connection.Method.POST)
.data(Constant.SchoolNotice.PARAM_PAGE_SIZE, "10")
.data(Constant.SchoolNotice.PARAM_PAGE_INDEX, String.valueOf(index))
.data(Constant.SchoolNotice.PARAM_A_TITLE, "")
.data(Constant.SchoolNotice.PARAM_ORDER_BY_TYPE, "asc")
.timeout(10000)
.execute();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例2: getCourseId
import org.jsoup.Connection; //导入方法依赖的package包/类
/**
* 获取课程id
*
* @param cookiesMap
* @return
*/
public static Response getCourseId(Map<String, String> cookiesMap) {
try {
Connection con = Jsoup.connect(Constant.CoursePraise.COURSE_URL);
con.ignoreContentType(true);
Iterator<Map.Entry<String, String>> it = cookiesMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> en = it.next();
con = con.cookie(en.getKey(), en.getValue());
}
return con.method(Connection.Method.GET)
.data(Constant.CoursePraise.COURSE_URL_OTHER_PARAM, "zTreeAsyncTest")
.data(Constant.CoursePraise.COURSE_URL_, "1507812989512")
.timeout(10000)
.execute();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例3: getCourseInfo
import org.jsoup.Connection; //导入方法依赖的package包/类
public static Response getCourseInfo(Map<String, String> cookiesMap, String id, String name) {
try {
Connection con = Jsoup.connect(Constant.CoursePraise.COURSE_URL);
con.ignoreContentType(true);
Iterator<Map.Entry<String, String>> it = cookiesMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> en = it.next();
con = con.cookie(en.getKey(), en.getValue());
}
return con.method(Connection.Method.GET)
.data("id", id)
.data("name", name)
.data("pId", "")
.data("level", "0")
.data(Constant.CoursePraise.COURSE_URL_OTHER_PARAM, "zTreeAsyncTest")
.data(Constant.CoursePraise.COURSE_URL_, "1507812989512")
.timeout(10000)
.execute();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例4: getConnect
import org.jsoup.Connection; //导入方法依赖的package包/类
public static Connection getConnect(String url, Map<String,String> header, Map<String,String> cookie){
Connection con;
// Document doc = null;
url = url.trim();
con = Jsoup.connect(url);
con.ignoreContentType(true);
// if(!url.startsWith("http:/")){
// return null;
// }
if(url.split(":", 2)[0].equals("https")){
con.validateTLSCertificates(false);
}
if(!(header==null||header.isEmpty())){
for(Object key : header.keySet()){
con.header((String) key, header.get(key));
}
}else{
con.header("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
}
if(!(cookie==null||cookie.isEmpty()))
con.cookies(cookie);
// try {
// doc = con.get();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();logger.error("Exception",e);
// }
con.ignoreHttpErrors(true).ignoreContentType(true);
return con;
}
示例5: createStringConnection
import org.jsoup.Connection; //导入方法依赖的package包/类
/**
* 构建一个返回类型为String的抓取连接
*/
public static Connection createStringConnection(boolean isUseProxy, String url, String cookie, String UA, String referer, String host) {
Connection connection = getConnection(url, cookie, UA, referer, host);
connection.header("Accept", "*/*");
return connection.ignoreContentType(true);
}