2017-02-22 62 views

回答

0

我會使用Jsoup,它可以輕鬆訪問文檔並提取信息。

的調用看起來像

//With this you login and a session is created 
    Connection.Response res = Jsoup.connect("http://techmvs.technion.ac.il:80/cics/wmn/wmngrad?aapmlkwi&ORD=1&s=1") 
     .data("username", "myUsername", "password", "myPassword") 
     .method(Method.POST) 
     .execute(); 

//This will get you cookies 
Map<String, String> loginCookies = res.cookies(); 

//Here you parse the page that you want. Put the url that you see when you have logged in 
Document doc = Jsoup.connect("urlYouNeedToBeLoggedInToAccess") 
     .cookies(loginCookies) 
     .get(); 

正如你可以看到你可以訪問餅乾,並利用它們開到禁區網址。示例取自Stackoverflow

0

使用retrofit-2和Ion或Loop j對您來說無論如何容易,但請牢記,這些庫不是Google提供的,但排除是Google庫,因此它不會被支付,但這些第三方庫可能會很痛苦未來。

從另一方面來說,這些庫提供了許多簡單易行的工作,並且具有更好的性能,如重試,緩存等。 所以現在您可以使用,但不能用於未來。

相關問題