Is there a way to record an action using PhantomJs / CasperJS or a similar browser without a browser?

Well, here is a brief description of the problem I'm trying to find for a solution.

Let's say we have an online service that can automate various online tasks (by clicking on the link, go to the page, select an option from the combo box and finally copy the address from the address bar). The site where I want to perform these actions is completely in JavaScript, and I want everything to be on the PHP endpoint, I mean php script to get parameters from users, transfer it to the JS server and get the result and show it back user.

How can I make such a scenario? Any ideas? I know that this can be done by analyzing the DOM elements in detail, but for a very long time and volatility. I just want to know if there is a way so that I can record this action, like what we can do with Selenium? How about this interaction with php ↔ Headless Browser?

+4
source share
2 answers

For manual recording part of the question, the combination of CasperJS + resurectio Chrome is really convenient.

+7
source

In your scenario where the web context that you are trying to crawl includes JavaScript, CasperJS is a great option. You can use it to trigger events, add process steps, enable functions to wait and verify after each ajax call before processing the next step.

Here is an example of how to use casperjs using javascript and jQuery.
CasperJs and jQuery with chain selection

Here is an example of how you can install casperjs as a service for transferring data to PHP.
CasperJS passes data back to PHP

+1
source

Source: https://habr.com/ru/post/1494754/


All Articles