Skip to content Skip to sidebar Skip to footer

Apache Httpclient 4 And Javascript

I Use Apache HttpClient to Access a webpage . i want to click on a link but the link is javaScript , how can i process click on a javascript link and follow url redirection ? sampl

Solution 1:

It looks like the page you are trying to get to uses AJAX to fetch the link. It would be difficult to emulate this behavior with just vanilla HTTPClient. HTTPClient is for "raw" HTTP communication, and not browser emulation. Instead, I recommend using something akin to HtmlUnit, which can emulate a browser and execute the JavaScript on the page: http://htmlunit.sourceforge.net/

HtmlUnit has rather good JavaScript support, but it is not perfect. If you need to rely on 100% perfect browser emulation, you need to use a browser automation framework such as Selenium: http://seleniumhq.org/

Post a Comment for "Apache Httpclient 4 And Javascript"