0

Is it possible to send the result of a Python script to the input field of a PHP page? I am using a PYTHON script to capture weight data from a scale. I would like to use that data from the python script, placing it into the input field of a PHP page. The name of the input field on the page will remain static, as will the name of the page. To initiate the process (from python script to the input field) I would use an on click command or something similar.

I am very new to python and very much appreciate any help.

Bob

3
  • Are you serving the php page? can't you make a request to the web server using python module requests? Commented Jun 9, 2017 at 20:19
  • You could use Selenium WebDriver for Python with which you can open and navigate your browser and then send_keys with your value to input. Although I have no clue what is purpose of your idea. Commented Jun 9, 2017 at 20:54
  • Thanks everyone for the help. The point of this is that I need to take the weight off of a scale and be able to place it on the I put field. I guess I assumed because the scale is a HID, I could pass that data onto anywhere a keyboard could be used. Commented Jun 10, 2017 at 0:52

2 Answers 2

0

You have to expose the data to the Internet - either create an upload script in PHP that will receive data whenever your Python script captures the new weight (you probably don't want this approach), or write a PHP script that will execute the Python script, take its output and send it back to you. You can then reload the whole page or use JavaScript to update the input field

Hope this helps you, comment if you have any questions

Sign up to request clarification or add additional context in comments.

Comments

0

I guess this is what you're looking for https://stackoverflow.com/a/5986282/7950984 .

Or you could create a server(running your php script) and post data to it, which will use your data as input. For this you could use CodeIgniter or a simplified REST Library RestServer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.