Skip to content

Commit

Permalink
requests.session()
Browse files Browse the repository at this point in the history
  • Loading branch information
RafayGhafoor committed Jul 16, 2017
1 parent 5962ce6 commit 369e176
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions ptcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 4 additions & 4 deletions router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 369e176

Please sign in to comment.