简体   繁体   English

如何使用 url 调用或 webhook 在服务器上执行 python 脚本

[英]How to execute python script on a server with an url call or webhook

enter image description here i need to execute a python script on my server by calling it from the server url or from a webhook, like http://myserver.net/myscript.py but i can't figure out how, i'm fairly new to this.在此处输入图像描述我需要在我的服务器上执行 python 脚本,方法是从服务器 url 或从 webhook 调用它,例如http://tpy figure out/myscript.对此相当陌生。 The script uses selenium and open a chrome window and get to google homepage.该脚本使用 selenium 并打开一个 chrome window 并进入谷歌主页。 I tried with a php file, using shell_exec command but it fails at opening the chrome window, probably because the script is executed by the apache profile.我尝试使用 shell_exec 命令使用 php 文件,但在打开 chrome window 时失败,可能是因为该脚本由 apache 配置文件执行。 The script runs fine when called in bash with my profile.使用我的个人资料在 bash 中调用该脚本时运行良好。 I heard about CGI to get ride of php but i don't know this at all.我听说 CGI 可以乘坐 php 但我根本不知道。 Any suggestion?有什么建议吗? Thanks谢谢

As per your error_log Chrome is not properly closed and says "Chrome has crashed".根据您的 error_log Chrome 未正确关闭并显示“Chrome 已崩溃”。 To execute python file and selenium chromedriver.exe the following things are properly checked:要执行 python 文件和 selenium chromedriver.exe,请正确检查以下内容:

  1. Go to Task manger and stop running chromedriver.exe (on Windows) Go 到任务管理器并停止运行chromedriver.exe (在 Windows 上)
  2. Close all running Google Chrome application.关闭所有正在运行的 Google Chrome 应用程序。
  3. Now hit your URL localhost/index.php?token=a现在点击你的 URL localhost/index.php?token=a

Note: You won't see selenium chromedrive window and google chrome window, but these are running as background process after you execute python by PHP shell_exec() command. Note: You won't see selenium chromedrive window and google chrome window, but these are running as background process after you execute python by PHP shell_exec() command.

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

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