I have a Python GUI that interacts with some lab devices by sending POSTs through the device webpage. I used chrome developer tools to find out what information to send for each function and this approach has worked for everything except one button on the webpage.
The pertinent output from developer tools is here
So I send this code as a post request
Post_data={'SUBMIT_FLOW' :'Zero Flow',
'PRES_VAL' :''}
Encoded_data=urllib.urlencode(Post_data)
Request = urllib2.Request(url+'/configure_html_zero', Encoded_data)
Every other time I have done this strategy the device will run the function I want it to, but for this function it doesn't work. If I unpack the response to that request I get
<addinfourl at 205604872L whose fp = <socket._fileobject object at 0x000000000EE8F408>>
Here is the section of HTML code that this function corresponds to
<td class="main_table_data">
<table ID="Zero" class="inner_table" cellspacing="0" width="100%">
<form name="config_zero" method="post" action="configure_html_zero">
<tr>
<td><input type="submit" value="Zero Flow" name="SUBMIT_FLOW" ID="ZeroFlow"></td>
</tr>
<tr>
<td> </td>
</tr> <!-- End Labels -->
<tr>
<td><input type="submit" value="Zero Pressure" name="SUBMIT_PRES" ID="ZeroPressure"><input type="text" name="PRES_VAL" size="10"></td>
</tr>
</form>
</table>
</td>
I don't know HTML at all so I don't know if this is valuable.
And, if it is of any interest, here is what the form looks like on the website
I'm not sending the data to the wrong URL, and I am using the same procedure as I have a dozen other times in my program. Any idea why this one is different? Does this have something to do with the blank value for "PRES_VAL"?
resp.read()
and resp.getcode()
should contain the description of any potential problem you're encountering. Is resp.getcode()
anything other than 2xx? You should check against https://en.wikipedia.org/wiki/List_of_HTTP_status_codes . If resp.read()
is very long then it likely has the content of an HTML page, you could save the contents in a HTML file and view it with a browser to check if it contains any indications of problems (validation errors). Without the actual device and the whole req/response info no one can help you except for providing debugging tips.