$client = new Client();
$a = 'https://scholar.google.com/citations?user=';
$gscID = 'EnegzCwAAAAJ';//for eg
$b = '&hl=en&oi=ao';
$url = $a . $gscID . $b;
$crawler = $client->request('GET', $url);
//python script
$process = new Process(['python', public_path() . '\ext.py'], null, ['SYSTEMROOT' => getenv('SYSTEMROOT'), 'PATH' => getenv("PATH")]);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
$out[] = $process->getOutput();
dd($out);
Extracting the tables from the given url webpage
Now I want to pass the $url
variable to the python script stored in my public folder because everytime my url changes with different person's ID.
Any help would be really appreciated
CodePudding user response:
You can add script parameters in the array that you are passing to Process. Here is the doc.https://symfony.com/doc/current/components/process.html#using-features-from-the-os-shell
CodePudding user response:
Found out an easy solution
$output = shell_exec("python ext.py $url");
//ext.py is name of my script and $url
is my variable which I want to pass
And then in python script write
import sys
url = sys.argv[1]