Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- from appJar import gui
- import requests
- DEFAULT_LINK = 'http://192.168.15.1/index.html' # Only for Vivo/GVT
- def acess_page():
- try:
- req = requests.get(DEFAULT_LINK)
- return req.text
- except Exception as e:
- raise e
- def extract_devices(content=None):
- if content is not None:
- soup = BeautifulSoup(content, 'lxml')
- txtarea = soup.find('textarea').text.split('DHCP')
- devices = [d[:d.find('MAC')] for d in txtarea]
- return list(filter(lambda x: len(x) > 1, devices))
- return -1
- def prettify(devices):
- for d in devices:
- yield('{}\n'.format(d.strip().replace('Hostname: ', '')))
- content = acess_page()
- devices = extract_devices(content)
- devices = list(prettify(devices))
- class Window(gui):
- """
- Subclassing appJar.gui
- """
- def __init__(self):
- super().__init__()
- self.setTitle('Dispositivos conectados')
- self.setResizable(False)
- self.setSize(350, 200)
- colours = ['white', 'black']
- coloursFg = colours[::-1]
- for i in range(0, len(devices)):
- self.addLabel(i, devices[i], colspan=2)
- self.setLabelBg(i, colours[i%2])
- self.setLabelFg(i, coloursFg[i%2])
- self.addWebLink("Clique aqui para informações em tempo real", DEFAULT_LINK)
- self.go()
- Window()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement