It looks like you are trying to create a web scrambling application. For this purpose, I recommend the HtmlUnit library.
This simplifies working with forms, proxies, and data embedded in web pages. Under the hood, I think it uses Apache HttpClient to handle HTTP requests, but this is probably too low level for you to bother.
Using this library, you can manage a web page in Java in the same way as you can manage it in a web browser: clicking a button, entering text, selecting values.
Here are some examples from the HtmlUnit top of the page :
Form Submission:
@Test public void submittingForm() throws Exception { final WebClient webClient = new WebClient();
Using a proxy server:
@Test public void homePage_proxy() throws Exception { final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_2, "http://myproxyserver", myProxyPort);
The WebClient class is single-threaded, so each thread that deals with a web page will need its own WebClient instance.
If you do not need to handle Javascript or CSS, you can also disable them when creating the client:
WebClient client = new WebClient(); client.setJavaScriptEnabled(false); client.setCssEnabled(false);
Iain elder
source share