从命令行运行基于DOM的Javascript [英] Run DOM-based Javascript from command line
问题描述
我有一些Javascript正在与网站上的DOM交互.
document.location.href ="https://www.example.com";
它在Chrome控制台上运行良好,但我想从命令行运行该代码.我该怎么做?NodeJS给出未定义文档"错误.
要使用命令行在浏览器的DOM中插入Javascript代码,您实际上需要... 运行Javascript代码广告的浏览器具有DOM.
您可以使用 Selenium 之类的东西或依靠在诸如 https://github.com/prasmussen/chrome-cli 的桥接库上>
I have some Javascript that is interacting with the DOM from a website.
document.location.href="https://www.example.com";
It works well from Chrome console, but I would like to run that code from the command line. How can I do it? NodeJS gives "document is not defined" error.
In order to use command line to inject Javascript code in a browser's DOM you actually need...a browser that runs Javascript code ad has a DOM.
You can go with something like Selenium or rely on a bridged library like https://github.com/prasmussen/chrome-cli
这篇关于从命令行运行基于DOM的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!