5

I try to get a proxy list from this url:

Free proxy list

This would be cool, but port number is dynamic JavaScript content. How can I get JavaScript-generated content from this page? I have jsoup and djNativeSwing but I want do this in background thread.

JWebBrowser webBrowser = new JWebBrowser();
webBrowser.navigate("http://spys.ru/en/free-proxy-list/");
System.out.println(webBrowser.getHTMLContent());

this code returns a Null result. Help please.

8
  • check out htmlUnit I think it is the one thing that you need. Thanks. Commented Aug 23, 2012 at 17:57
  • i think this is not for me. My code must be simple and crossplatform. As i know HTMLUnit - must have SYSTEM path - it's trouble Commented Aug 23, 2012 at 18:13
  • No you do not need system path. I created web crawler using HTMLUnit which works on http protocol. so yes it does work properly. Let me know if you want more help. I can write a formal answer if you want. Commented Aug 23, 2012 at 18:23
  • Ohhh! Give me example! I try to use this! Commented Aug 23, 2012 at 18:27
  • I'm try to use this code: final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("spys.ru/free-proxy-list1/RU/"); System.out.println(page.toString()); Commented Aug 23, 2012 at 18:31

1 Answer 1

2

The webbrowser hasn't finnished loading when you call the getHtmlContent() method. Use something like this instead:

JWebBrowser webBrowser = new JWebBrowser();
webBrowser.navigate("http://spys.ru/en/free-proxy-list/");
webBrowser.addWebBrowserListener(new WebBrowserListener(){
   public void loadingProgressChanged(WebBrowserEvent e){
       if(e.getWebBrowser().getLoadingProgress()==100)
            System.out.println(webBrowser.getHTMLContent());
   }
}
/* Note: I wrote this in the comment field without any testing,
   you probably have to make the webBrowser final. */

JavaDocs is your friend!

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for fast replay, but i nothig to get from this code. And how to not building all abstrcat class for event.
2 secs, I'll try to get the lib and test it out
Sorry, I'm not familiar enough with the library. Even if I use a timer to wait for a long period of time, webBrowser.getHTMLContent() returns null for some reason
Do yo have any ideas? I'm try to use this example to and so it is

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.