简体   繁体   English

在网站上运行JavaScript命令

[英]Run JavaScript command on website

I have a home automation system which has a small Linux server and an app to control my lighting system. 我有一个家庭自动化系统,该系统具有小型Linux服务器和一个用于控制照明系统的应用程序。 The problem is that this system is too limited for my use, so I wanted to create a desktop app (Java or C#) to send my own data to the server. 问题是该系统的使用空间太有限,因此我想创建一个桌面应用程序(Java或C#)以将自己的数据发送到服务器。

When I log into the webpage, I can just use FireFox' JavaScript console to send the commands. 登录网页后,我可以使用FireFox的JavaScript控制台发送命令。 But my question is how I can log into a webpage and send JavaScript data to it programmatically. 但是我的问题是如何登录到网页并以编程方式向其发送JavaScript数据。

I also tried sending the data through a WebSocket or TcpClient, but I have no idea how that works. 我也尝试通过WebSocket或TcpClient发送数据,但我不知道它是如何工作的。

You just have to perform the same requests than the browser when you are on the website, that is (most probably) HTTP GET and HTTP POST. 在网站上时,您只需要执行与浏览器相同的请求,即(很可能是)HTTP GET和HTTP POST。 It is possible to send the request with any programming language, including JavaScript. 可以使用任何编程语言(包括JavaScript)发送请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM