python certificate problem
Hi,
I am trying to connect to the HD 12 rainmachine using a python script locally for a home automation program. I keep getting certificate errors because the non verifiable certificate can't be verified. No surprise. In curl, I can add -k to ignore this, but I am struggling to figure out how to do the same.
Any help would be great!
-Geoff
Here is a very simple example:
from urllib2 import Request, urlopen
request = Request(
'https://xxx-my-ip-address-xxx:8080/api/4/zone/1/stop?accesstoken=xxx-my-access-token-goes-here-xxxx'
)
response_body = urlopen(request).read()
print response_body
-
Hey Geoff,
I played around this and had some success using the following code (tested on RainMachine Mini-8).
#!/usr/bin/python
import requests#Disable cert warning
requests.packages.urllib3.disable_warnings()#Set variables
rm_accesstoken = "xxx-my-access-token-goes-here-xxxx"
rm_host = "xxx-my-ip-address-xxx"# Create request and set cookies
request_path = ('https://%s:8080/api/4/machine/time' % rm_host)
rm_cookies = dict(access_token=rm_accesstoken)# Request (verify=False disables cert check)
r = requests.get(request_path, cookies = rm_cookies, verify=False)
print r.textRegards,
Sam
Please sign in to leave a comment.
Comments
1 comment