标签:
#!/usr/bin/env python3 #-*-encoding:utf-8-*- import re import os import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.error, urllib.parse import http.cookiejar filename = ‘/tmp/cookie.txt‘ cookie = http.cookiejar.MozillaCookieJar(filename) opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie)) postdata = urllib.parse.urlencode({‘username‘ : ‘username‘, ‘userpwd‘ : ‘password‘}).encode(encoding=‘UTF8‘) loginUrl = ‘http://xxxx/login‘ result = opener.open(loginUrl,postdata) cookie.save(ignore_discard=True, ignore_expires=True) gradeUrl = ‘http://xxxx‘ result = opener.open(gradeUrl) ‘‘‘以上是抓取网页数据,下面是筛选地址‘‘‘ file = result.read().decode(‘utf-8‘) r = file.partition(‘所有已启用且异常‘) file = r[2] p=re.compile(‘[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}‘) list_mac = p.findall(file) p=re.compile(‘[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{4,5}‘) list_ip = p.findall(file) p=re.compile(‘秘密‘) list_user = p.findall(file) ip_user = list(zip(list_ip, list_user)) name = dict(zip(list_mac, ip_user)) for i in name.values(): user = i[1] ip = i[0] os.environ[‘user‘] = str(user) os.environ[‘ip‘] = str(ip) os.system(‘rdesktop -u ${user} -p password -a 16 -r clipboard:PRIMARYCLIPBOARD ${ip} &‘)
标签:
原文地址:http://www.cnblogs.com/hygs/p/5464588.html