-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathwebsite.py
More file actions
30 lines (22 loc) · 771 Bytes
/
website.py
File metadata and controls
30 lines (22 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
import requests
from requests import exceptions
import sys
URL = 'https://www.google.com'
STRING = '<title>Google</title>'
try:
response = requests.get(URL, verify=True)
if STRING in response.content:
print "OK | status_code=%s;;;; time=%s;;;;" % (str(response.status_code),
str(response.elapsed.total_seconds()) + 's')
sys.exit(0)
else:
print "Plugin Failed! String %s not found" % STRING
sys.exit(2)
except exceptions.SSLError:
print "Plugin Failed! SSL Certificate verification failed."
sys.exit(2)
except exceptions.ConnectionError, e:
if "Connection refused" in str(e):
print "Connection Refused"
sys.exit(2)