我有一个python脚本,用于使用selenium进行抓取。当我用这样的终端调用我的脚本时/usr/bin/python3 /home/scraping.py
我的刮擦工作没问题
去尝试用php调用同一个脚本不起作用。在
在我的python脚本上有这个
^{pr2}$
当我删除这行时driver =webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs')
driver.set_window_size(1024, 768)
driver.get(url)
page = driver.page_source.encode("utf-8")
我把justeprint('test')
我这工作
对于我的php文件
但什么都不管用
我在尝试更改^{的组文件时将权限文件改为chmod 777 scraping.py我试图将www数据放入soduers文件
在我的php代码中我有tri这个output = array();
exec("/usr/bin/python3 /home/scraping.py",$output);
var_dump( $output);
$command = escapeshellcmd('/usr/bin/python3 /home/scraping.py');
$output = shell_exec($command);
echo $output;
ob_start();
passthru('/usr/bin/python3 /home/scraping.py');
$output=ob_get_clean()
编辑
我发现了我的问题
问题是phantomjs和shebang生成的日志文件在我的代码中是这样的#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from selenium import webdriver
driver =webdriver.PhantomJS( service_log_path='/home/ghostdriver.log'executable_path='/usr/local/bin/phantomjs')
driver.set_window_size(1024, 768)
driver.get(url)
page = driver.page_source.encode("utf-8")
print(page)
在改变了ghostdriver.log对于www数据可以读取id您又有一个错误,请将组www数据放入sudoers文件中,没有密码