diff --git a/ptcl.py b/ptcl.py index 8d01ffb..38f95d4 100644 --- a/ptcl.py +++ b/ptcl.py @@ -10,27 +10,27 @@ def main(): parser.add_argument('-r', '--restart', help="Restart Router.") parser.add_argument('-s', '--show', help='Show Active Devices.') args = parser.parse_args() - + if args.block: ptcl.show_active_dev() dev_mac = raw_input("Please Enter Device Mac Address: ").upper() ptcl.block_dev(dev_mac, get_sessionkey()) - + elif args.unblock: ptcl.show_active_dev() udev_mac = raw_input("Please Enter Device Mac Address: ").upper() ptcl.unblock_dev(udev_mac, get_sessionkey()) - + elif args.restart: ptcl.reboot_router(get_sessionkey()) elif args.show: print "Showing Active Devices" - ptcl.get_dhcpinfo() - + ptcl.show_dhcpinfo() + else: print "Invalid Argument" - + main() diff --git a/router.py b/router.py index 8c9da94..64e318d 100644 --- a/router.py +++ b/router.py @@ -33,13 +33,13 @@ def __init__(self, mask="http://192.168.1.1", username="admin", password="admin" self.mac_address = [] # Devices Mac Address self.active_dev = [] # Active Devices on Wi-Fi self.mac_and_host = {} # Mac Addresses and Hostnames - # self.sessionkey = sessionkey + self.session = requests.Session() + self.session.auth = (self.username, self.password) - @staticmethod - def scrape_page(url): + def scrape_page(self, url): '''Scrape given link and create a beautiful soup object''' - request_url = requests.get(url, auth=('admin', 'BB815')) + request_url = self.session.get(url) html_soup = bs4.BeautifulSoup(request_url.content, 'html.parser') return request_url, html_soup