简体   繁体   English

从网站在本地计算机上触发Python脚本

[英]Trigger Python script on local machine from Website

I have a WordPress site running on an external server, I also have a local machine running a Python script. 我有一个在外部服务器上运行的WordPress网站,也有一个运行Python脚本的本地计算机。

I am looking for a way to trigger the python script from the WordPress install. 我正在寻找一种从WordPress安装触发python脚本的方法。

I know I can use the publish_post hook in WordPress to activate whenever a new post is published but I am unsure of the best way to link that to my local machine. 我知道我可以在发布新帖子时使用WordPress中的publish_post钩子来激活它,但是我不确定将其链接到本地​​计算机的最佳方法。

Anyone have an example of something similar being done? 有人举过类似的例子吗? Would the WordPress Rest API be of any use here? WordPress Rest API在这里有用吗?

The only safe way I can think of is to "poll" the website from the local machine. 我能想到的唯一安全的方法是从本地计算机“轮询”网站。 It is impractical and insecure to access the local machine from the website. 从网站访问本地计算机是不切实际和不安全的。

You need to find a condition that changes and can be examined using the local script and use that to determine whether to take the necessary action or not. 您需要找到一个可以更改的条件,并且可以使用本地脚本进行检查,并使用该条件来确定是否采取必要的措施。 This could be another PHP script on the WordPress site giving you state information, or just a web call locally. 这可能是WordPress网站上的另一个PHP脚本,可以为您提供状态信息,也可以只是本地的网络调用。

WordPress wouldn't have access to your python script. WordPress无法访问您的python脚本。 But you python script has access to WordPress. 但是您的python脚本可以访问WordPress。 It should periodically fetch the data from the WordPress installation URL / Blog page. 它应该定期从WordPress安装URL /博客页面获取数据。 And this will have to be scheduled periodically like every 4 hours if that's how frequently the posts are published. 而且,如果发布的频率如此高,则必须像每4个小时一样定期进行安排。

暂无
暂无

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

相关问题 从Web服务器在AWS上触发Python脚本 - Trigger a Python Script on AWS from Web Server 如何从本地计算机上的网页执行Python和.bat脚本 - How to execute Python and .bat scripts from a web page on local machine 为什么我不能从本地linux机器上的远程linux服务器上运行可运行的PHP网站? - Why I'm not able to run the working PHP website from remote linux server on my local linux machine? 将Drupal网站从服务器迁移到本地ubuntu 16.04计算机时出现奇怪的“服务不可用错误500” - Strange “Service Unavailable Error 500” when migrating a Drupal website from server to local ubuntu 16.04 machine 当在该网站中配置本地计算机的IP时,是否存在网站(远程)与设置本地计算机通信的方式? - Is there a way where a website (remote) would talk to a set local machine when the ip of the local machine is configured in that website? 使用 PHP 执行存储在用户本地计算机上的服务器/网络位置上的 python 脚本 - Execute a python script stored on a server/network location on a user's local machine using PHP 从本地 PHP 脚本运行远程 python 脚本 - Running remote python script from local PHP script 从(本地)python脚本运行(远程)php脚本 - Run (remote) php script from (local) python script 从iPhone连接到本地计算机 - connect to local machine from iphone 从网站(php)运行时如何停止python脚本 - How to stop python script when run it from Website (php)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM