php调用python并传递参数
exec("D:\python3.7\python D:\\python3.7\\test.py {$_REQUEST['url']}");
<?php
class getSource{
public $con='';
function __construct()
{
$this->con=mysqli_connect("localhost","root","root","yingshi");
}
function findSource()
{
$sql = "select source from source where url='".$_REQUEST['url']."'";
$result=mysqli_query($this->con,$sql);
while($arr=mysqli_fetch_array($result,MYSQL_NUM)){
$source=$arr[0];
}
if($source)
{
return $source;
}else{
return false;
}
}
function getSource()
{
$source=$this->findSource();
if($source)
{
return $source;
}else{
exec("D:\python3.7\python D:\\python3.7\\test.py {$_REQUEST['url']}");
sleep(30);
return $this->findSource();
}
}
}
$test=new getSource();
$source=$test->getSource();
网友评论