Xmind Java資料抓取

2021-09-12 21:16:35 字數 1013 閱讀 6647

思路:1,登入。2,登入成功後獲得cookie。3,將cookie放到請求頭中,向登入頁傳送請求。

1.獲得url物件

url url =newurl(urlstring);

2.開啟連線

3.向request中注入cookie

urlconn.setrequestproperty("cookie", cookie);

4.建立字元緩衝輸入流(bufferedreader)

bufferedreader br =newbufferedreader(newinputstreamreader(urlconn.getinputstream(),charset));

public class crawtest  

} catch (malformedurlexception e) catch (ioexception e)

return html.tostring();

} //傳送post請求,並返回請求後的cookie

private static string postgetcookie(string urlstring,string params,string charset) catch (malformedurlexception e) catch (ioexception e)

return cookies;

} public static void main(string args)

}

Jsoup抓取資料

首先我們來看來自 的乙個html片段,了解其結構。class detail style display block class add jrsj plus bookid 609737 em class mark63 href target blank src alt 不死龍帝 style width...

Urllib資料抓取

python 3中,urllib是乙個收集幾個模組來使用url的軟體包,具備以下幾個功能 urllib.request.urlopen url,data none,timeout,data 預設值為none,表示請求方式為get,反之為post timeout 超時設定 匯入urllib impor...

Request資料抓取

requests是在urllib的基礎上進一步封裝的,具備urllib的所有功能。安裝 http的常用請求是get和post。get請求 get請求又兩種形式,帶引數和不帶引數。不帶引數 帶引數 s?wd python一般 末端帶有 表示帶引數,反之,則不帶引數 get引數說明 帶引數的url的兩種...