我有一个关于 python 和 javascript 的问题。我喜欢创建一个与 javascript 网页通信的文件。
首先,我将创建一个 Python 文件,该文件将打开本地网页。此示例 localhost/test.html
此页面是模板页面。代码是
<html><head><title>An example application</title></head>
<script>
function myFunction()
{
alert("Hello! I am an alert box!");
}
</script>
<body>
<h1 class="content">This is my sample application</h1>
Put the content here...
<hr>
<a href="/exit">Quit</a>
</body></html>
当所有内容都加载并显示后,Python 文件将激活 javascript 函数“myFunction()”
我怎么做?我正在运行 Debian 并安装了 Python 和 Chromium。
您需要一个库来允许浏览器和程序之间进行交互。
选项包括Selenium and Ghost.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)