centos7+php+mysql+python将爬虫结果显示到网页上

php执行控制台指令

$output = shell_exec('');

添加apache权限

~ visudc = vi /etc/sudoers
root    ALL=(ALL)       ALL
apache  ALL=(ALL) NOPASSWD: ALL

关闭selinux

setenforce 0

shell_exec使用python3的路径

$output = shell_exec('sudo /.../python');

python防编码错误

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")

解决无头浏览器路径问题

driver = webdriver.PhantomJS(executable_path='...\phantomjs')

php-mysql搜索字符串要加引号

'............... word = \''.$word.'\'';

 

你可能感兴趣的:(centos7+php+mysql+python将爬虫结果显示到网页上)