I want to pass the variable from php to python and i use this code for that:
php
<?php
$item='http://www.google.com';
$tmp = passthru("python test.py ".$item);
python
from selenium import webdriver
import sys
link = sys.argv[1]
chrome_path = r"C:\Users\user\Downloads\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get(link)
s = driver.page_source
and this works fine, but now in this process, I want to pass this variable s from python in the PHP, can I do it somehow in one step, when I pass the variable from PHP to python to receive the result of python code again in the PHP
1 Answer 1
This should work
from selenium import webdriver
....# your code here
print(driver.page_source)
in PHP
$tmp = shell_exec('python test.py ' . $item);
Now your $tmp should have driver.page_source value
Sign up to request clarification or add additional context in comments.
2 Comments
xxbinxx
@dssada what's your python version?
default
shell_exec, usingshell_execrun your python script which returns ajson, this will get stored in yourshell_execvar. Won't this work?