'chromedriver.exe文件'可执行文件需要在路径中'

2024-05-17 06:32:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在编写一个Python文件,当nodejs服务器请求时,可以使用chromeweb驱动程序对其进行爬网。你知道吗

我已经用了ChromeWeb驱动程序的绝对路径。 我试过模块'webdriver-manager',但它说'No module named 'webdriver_manager''

文件目录结构

project
  L module
    L crawling
      L chromedriver.exe
      L crawling.py
  L router
    L controller
      L api
        L index.js

节点.js服务器:索引.js

router.get('/', async(req, res) => {
    const filePath = path.join(__dirname, '..', '..', '..', 'module', 'crawling') + '/crawling.py';

    pythonShell.PythonShell.run(filePath, null, (err, result) => {
        console.log(result)
        if (err) {
            console.log(err.message)
        } else {
            console.log('finished');
        } 
    })

python代码:爬行.py

...
driver = webdriver.Chrome()
driver.implicitly_wait(30)
...

我希望在向服务器发出请求时,能够用web驱动程序爬行。你知道吗


Tags: py服务器logdriver驱动程序jsmanagerresult