I want to launch a python script similar to this web crawler, wait for it to finish, process the data in php, then return the results to the user.
From what I hear, getting the output from python is trivial, but the above script is doing stuff in parallel, so just printing stuff as it finishes won't give me any kind of usable structure.
What would you suggest to use to pass an array of html data from the python scri开发者_JAVA技巧pt to php? A temporary file? mysql? I have no experience whatsoever in python, so you'll need to be pretty explicit.
Cheers.
I suggest a file, you can dump structured data for example to JSON or YAML (both is easily writable and readable in both Python and PHP).
Why is "printing stuff as it finishes" not usable? Writing file and then reading it is basically the same. You don't have to use only print
in Python, you can use standard output (sys.stdout
) in the same way as a opened file.
精彩评论