• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HtmlUnit for Android

 
Roberto Tucci
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm developing an app and I need to retrieve data from html code. In addition, i would like manage the event (for example, click the button and redirect in other page) in html code.
I searched on Google and I've found a beautiful library that meet my needs: HtmlUnit.
The problem is the compatibility with Android SDK: there are conflicts with Android classes and maybe, I must to recompile the source code for Android compatibility.
Are there alternative to HtmlUnit? I don't know how to build this library...Can you help me?

Any help would be most welcome...thank you!

PS: sorry for my poor english!
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The good news is that getting and building HtmlUnit is pretty easy. http://htmlunit.sourceforge.net/gettingLatestCode.html shows how in "Checking out SVN repository" and "Compiling the code" assuming you have Subversion and Maven installed.

The bad news is that HtmlUnit uses Java classes that are not available on Android. These are the AWT, Swing and ImageIO classes that came to my mind; there may be other APIs I'm not thinking of:

On top of that, HtmlUnit uses a bunch of other libraries, some of which may have their own dependencies on these libraries. So, as awesome as HmlUnit is, I think getting it to run on Android may not be an easy task.
 
Roberto Tucci
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!
So, I understood. Mmm...is not an easy task.
According to you, are there similar alternative to HtmlUnit? Mainly, I need to get html and simulate a button click...

Thanks!
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is one specific web page in which you need to simulate one specific action, you might use Android's built-in HttpClient library. It's fairly easy to code up a form submission with that.

If you need more flexibility (several forms, data extraction from the web page, different web pages, etc.) you could run HtmlUnit as part of a Java web app, and have the Android app communicate with it over a REST API. That might be way over-engineered, depending on your requirements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic