0

I am using phantom js to achieve automation by capturing screen information.

After processing the captured information, the success/failure status is to be denoted to an API by executing Http POST. What is the best way to achieve this ?

I tried to use phantom-js via the node js bridge but it is not reliable as mentioned here : https://stackoverflow.com/a/15746154/590589
What are the other options that I can use ?

Thanks for the help.

Pratham
  • 1,522
  • 1
  • 18
  • 33
  • `I tried to use phantom-js via the node js bridge` show what you've tried, please. "it is not reliable" is not an excuse, have you *personally* ran into its unreliability? – Vaviloff Sep 13 '17 at 11:04

1 Answers1

0

Adapted from post.js, an official PhantomJS example:

var page = require('webpage').create(),
    hq = 'http://example.com/scrape.php',
    data = 'success=1';

page.open(server, 'post', data, function (status) {
    if (status !== 'success') {
        console.log('Unable to report to HQ!');
    } else {
        console.log('Payload sent');
    }
    phantom.exit();
});
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • This helps, but as mentioned the page is already created. This method along with a solution from `https://stackoverflow.com/questions/16996732/using-multiple-page-open-in-single-script` is what is required. – Pratham Sep 12 '17 at 08:55
  • 1) maybe try and create a second page object? 2) Nowhere in the opening script you mentioned multiple URLs. 3) Stackoverflow is not a code writing service, I don't get what you mean by "required". – Vaviloff Sep 12 '17 at 15:42
  • 1) as mentioned in the question I am capturing the screen info using phantomjs (that's url one) and have to send the success/failure status to an api (2nd url). 2) Creating a second page does not work, we need to use a solution from the question link in the earlier comment. 3) the comment is to help others facing similar issue by providing more info. Thanks – Pratham Sep 13 '17 at 05:43
  • Errr... why do we need the solution in the question link? Do you use PhantomJS with node.js? – Vaviloff Sep 13 '17 at 11:01