domingo, 26 de setembro de 2010

Search about Fish

HI HI HI!

JavaFX Script is dead. No, it isn't, it will rebirth as Visage. You know I love JavaFX Script because it's easy and fast to build what you want. Anyway, JavaFX will be better on next months...

Well, I'm presenting another JavaFX app tagged as Useful, at least for me and some brazilian fishers... Our goal is to search basic information about fishes using the art of Screen Scrapping. The information is in Portuguese, because the easiest page I found to scrap  was in Portuguese...

I'm using Google images too. Take a look below, all I can say is: JavaFX is great.


public function getFishImages(fishName: String, callback: function(: String[]): Void) {
    var urls: String[];
    imageRequest.stop();
    imageRequest = HttpRequest {
                location: "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q={fishName}&rsz=large&start=1"
                onError: function(e){println(e)}
                onInput: function(is: InputStream) {                    
                    def parser:PullParser = PullParser {
                                documentType: PullParser.JSON
                                input: is
                                onEvent: function(e: Event) {                                    
                                    if (e.type == PullParser.END_VALUE) {
                                        if (e.name == "url") {
                                            insert e.text into urls;
                                        }
                                    }
                                    if (e.type == PullParser.END_DOCUMENT) {
                                        callback(urls);
                                    }
                                }
                            }
                            parser.parse();


                }
            }
            imageRequest.start();;
}


The app:
Want to search information about fish? This JavaFX app can he... on Twitpic

Now you can run the app and/or download the source.

If you are still interested in JavaFX Script you should check my humble JavaFX applications page :).

Peace.

2 comentários:

  1. Willian, very god app!
    The JavaFX Script is very good!
    Thanks for the source code!
    Here, Leonardo Fabris from the group.
    Thanks again!

    ResponderExcluir