skip to Main Content
$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

2

Answers


  1. Chosen as BEST ANSWER

    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]
    

  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search