本文整理匯總了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);
}