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

Bob K
  • 1
  • 1
  • Are you serving the php page? can't you make a request to the web server using python module `requests`? – DSLima90 Jun 09 '17 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. – Jan Giacomelli Jun 09 '17 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. – Bob K Jun 10 '17 at 00:52

2 Answers2

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

Markaos
  • 659
  • 3
  • 13
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.

darknite
  • 48
  • 7