Skip to content

Instantly share code, notes, and snippets.

@nemith
Created February 24, 2013 19:26
Show Gist options
  • Select an option

  • Save nemith/5025160 to your computer and use it in GitHub Desktop.

Select an option

Save nemith/5025160 to your computer and use it in GitHub Desktop.
class XbeeCableModem(object):
def __init__(self, ip, user="user", passwd="user"):
self.ip = ip
self.user = user
self.passwd = passwd
def _get_body_for_page(self, page):
url = "http://{}/{}.asp".format(self.ip, page)
r = requests.get(url, auth=(self.user, self.passwd))
doc = html.fromstring(r.text)
body = doc.xpath("//comment()[. = '------------START MAIN BODY HERE--------------------']/following-sibling::*[1]")
if not body:
### Raise a better exception
raise Exception
return body[0]
def get_downstream(self):
for row in self._get_body_for_page("CmDnstream").xpath(".//table/tr"):
heading = row.xpath('.//td[1]')[0].text_content()
if isinstance(heading, str):
heading = heading.strip()
if heading:
print heading
if __name__ == '__main__':
modem = XbeeCableModem("192.168.100.1")
modem.get_downstream()
Frequency
Lock Status
(QAM Lock/FEC Sync/MPEG Lock)
Channel Id
Modulation
Symbol Rate
(Msym/sec)
Interleave Depth
RxMER (dB)
CorrectableCodewords
UncorrectableCodewords
<tr>
<td align="left"><font size="2"><b>Lock Status <br>
(QAM Lock/FEC Sync/MPEG Lock)</b></font></td>
<td align="left"><font size=2>Y/Y/Y</font></td><td align="left"><font size=2>Y/Y/Y</font></td><td align="left"><font size=2>Y/Y/Y</font></td><td align="left"><font size=2>Y/Y/Y</font></td>
</tr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment