Apache HttpClient 4 And JavaScript

前端 未结 1 1841
野趣味
野趣味 2020-12-06 15:18

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

相关标签:
1条回答
  • 2020-12-06 16:06

    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/

    0 讨论(0)
提交回复
热议问题