I am trying to send array of URI's from my php to my python scraper. the array contains links to scrape.
I got example from here, and it worked fine with sending array of integer, but when I try to fill the array using URI's, error showed up.
php snippet:
$array = ["https://www.google.com/","https://www.google.com/","https://www.google.com/"];
//$array = [1,2,3]; // This is worked fine
$resultScript= system('python C:\xampp\htdocs\selenium\dummy.py ' .escapeshellarg(json_encode($array)));
$resultData = json_decode($resultScript, true);
var_dump($resultData);
python :
import sys
import json
def jsontoarray(json_data):
data = json.loads(json_data)
print(json.dumps(data))
jsontoarray(sys.argv[1])
print(data)
result from my IDE
Traceback (most recent call last):
File "C:\xampp\htdocs\selenium\dummy.py", line 8, in <module>
jsontoarray(sys.argv[1])
File "C:\xampp\htdocs\selenium\dummy.py", line 6, in jsontoarray
data = json.loads(json_data)
File "C:\Users\PC2\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Users\PC2\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\PC2\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 3 (char 2)
NULL
Process finished with exit code 0