首页 > 解决方案 > Issue trying to convert Python with Selenium module to JavaScript using Brython

问题描述

I am currently trying to code a Chrome extension that should run a program in the background, however I have written this code in Python as I am more familiar with this language than JavaScript. Since obviously Chrome extension only works with JavaScript, I am trying to compile my Python code using Brython. My issue is that I have used the Selenium module within my Python code and Brython is having issues detecting it. I've tried including: <body onload="brython({debug:1, pythonpath:['c:\\users\\anastasialauri\\appdata\\local\\programs\\python\\python39\\lib\\site-packages']})"> however an error: Not allowed to load local resource shows up on the html page. Below is my html code trying to test running the Python script. I would appreciate any help please!

<html>
    <head>
        <meta charset="utf-8">
        <script type="text/javascript" src="brython.js"></script>
        <script type="text/javascript" src="brython_stdlib.js"></script>
    </head>
    <body onload="brython({debug:1, pythonpath:['c:\\users\\anastasia lauri\\appdata\\local\\programs\\python\\python39\\lib\\site-packages']})">
        <script type="text/python" src="Applet.py"></script>
    </body>
</html>```

标签: javascriptpythonbrython

解决方案


推荐阅读