Reputation: 16056
I want to create a script to do certain actions on a web page on a schedule. I know there are browser extensions such as Greasemonkey or Selenium that I can use but my requirement is that the script should run from a command prompt. My preferences are PowerShell and NodeJS, or any .NET solution. One thing I was wondering was is it possible to record some web interaction in a .HAR file and then execute it, or is the .HAR format only used for logging network traffic and cannot be re-run? Thanks!
Upvotes: 0
Views: 2104
Reputation: 6940
If you are not limited by the browser type I think that the PowerShell is the best choice.
It covers all your requirements, like
create a script to do certain actions on a web page on a schedule.
and
the script should run from a command prompt.
and its a
.NET solution.
Since it is developed for task automation and configuration management. Consisting of a command-line shell and associated scripting language built on the .NET Framework. Also provides full access to both local and remote systems and network devices.
I have such scripts in these my articles - custom script #1 and custom script #2.
The Windows Task schedular will manage the launch of your scripts at pre-defined times or after specified time intervals.
Update
About the jQuery injection in PowerShell script you can try one of these:
Upvotes: 1
Reputation: 129
I've never seen a tool to execute a .HAR file directly, although there is enough information in a HAR file that you could write a tool to parse it and replay some of the requests.
The approach I would use, however, is to either write a shell script that executes cURL commands that perform the actions you need (in Chrome you can get a cURL command for a request from the network tab of the developer tools), or if the interaction is too complex, try writing a PhantomJS script that can do what you need.
Upvotes: 1