Currently, I am using the HttpClient POST method to perform a specific action on a website. This involves using Javascript for an ajax connection which generates a unique requestID in the form of
var reqID = Math.floor(Math.random()*1000001);
. I need to access this reqID in order to successfully carry out the action. Can anyone provide guidance on how to access Javascript in HttpClient? Alternatively, is it possible to access the reqID variable using HtmlUnit?
The Javascript code snippet includes:
ajaxConnection.prototype.execute = function() {
var reqID = Math.floor(Math.random()*1000001);
var params = "reqID=" + reqID ;
for (var key in this.connection_parameters) {
params += "&" + key + "=" + this.connection_parameters[key];
}
I am making a POST request to achieve the desired action like so:
String Src = PageSource_Post("http://www.example.com/ajax/ratingClient.php", new String[][]{{"reqID",""},{"id", "329602"},{"cmd", "rate"},{"rating", "2"},}, null);
At present, the reqID field is left blank while other parameters are obtained from the page source. Additionally, I am exploring the use of HtmlUnit:
webClient.setJavaScriptEnabled(true);
HtmlPage firstPage = webClient.getPage("http://www.example.com/");
HTMLScriptElement script = new HTMLScriptElement();
From this point onward, how can I access the specific reqID
variable?