2015-09-15 130 views

回答

2

您應該使用POST請求刮一些參數的網頁搜索和標題,試試下面的代碼:

Document doc = Jsoup.connect("http://www.davidsassoonlibrary.com/index.php?action=book_details") 
    .data("search", "search") 
    .data("title", "Test Cricket Lists") 
    //fields which are being passed in post request. 
    .userAgent("Mozilla") 
    .post(); 
    System.out.println(doc); // will print html source 

這是在控制檯上的結果:

Code and console

你可以使用螢火蟲去調用哪個URL被調用,方法GET或POS以及參數。

Post URL and parameters

+0

它工作完美。非常感謝你,但是.userAgent做了什麼?除了它,我已經得到了你的全部代碼 – gireesh

+0

在許多例子中,你會發現用戶代理設置爲Mozilla,該網站可以根據你的請求重新調用不同的html用戶代理(移動/非移動版本的站點) –

+0

再次感謝你 – gireesh