Created
March 4, 2019 21:14
-
-
Save zarya/52b603146faac2b3d42e417532975054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import requests | |
import sys | |
from html.parser import HTMLParser | |
class MyHTMLParser(HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
if tag == "meta": | |
if attrs[0][1] == "powerstate": | |
port = attrs[1][1].split(",") | |
if self.port == int(port[0]): | |
if port[1] == "1": | |
print("ON") | |
else: | |
print("OFF") | |
parser = MyHTMLParser() | |
if len(sys.argv) < 3: | |
raise Exception('your missing something') | |
parser.port = int(sys.argv[2]) | |
if len(sys.argv) > 3: | |
url = "http://%s/SWOV.CGI?s%i=%i" % (sys.argv[1],int(sys.argv[2]),int(sys.argv[3])) | |
r = requests.get(url) | |
else: | |
url = "http://%s" % sys.argv[1] | |
r = requests.get(url) | |
parser.feed(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment