开发者

Login to external site? (Android)

With java in android, is it possible to login to a website so that an html page can be parsed?

I've heard that with computers there's a script called cURL can be used, but is there any such 开发者_C百科thing with/for android?

thanks (:

EDIT:

I've found a site login which can be achieved using the following method with jsoup:

Connection.Response res = Jsoup.connect(url)
        .data("username", "john doe", "password", "mypass")
        .method(Method.POST)
        .execute();

But currently, I'm getting an SSL error with this method which I'm not sure how to fix.


Sorry, unless the website in question supports oAuth, you will need to build your own client. This entails sending the proper HTTP requests with the users credentials and storing the cookie for later use. Look into HttpClient and related classes.

For parsing, I would suggest a library like jTidy that can read almost everything and give you a proper DOM which you can work on with any XML library you want.

On the third hand, have you considered that the site may already have an API?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜