Created
September 14, 2017 19:22
-
-
Save Disassembler0/038462d46d2e8369422d0da1693b3c9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from lxml import html | |
import argparse | |
def main(args): | |
index = '/srv/portal/index.html' | |
doc = html.parse(index) | |
if args.property == 'link': | |
selector = '//div[@id="{}"]//a'.format(args.application) | |
node = doc.xpath(selector)[0] | |
node.set('href', args.value) | |
elif args.property == 'login': | |
selector = '//div[@id="{}"]//span[@class="login"]'.format(args.application) | |
node = doc.xpath(selector)[0] | |
node.text = args.value | |
elif args.property == 'password': | |
selector = '//div[@id="{}"]//span[@class="password"]'.format(args.application) | |
node = doc.xpath(selector)[0] | |
node.text = args.value | |
doc.write(index, encoding='utf-8', method='html') | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Portal property replacement tool') | |
parser.add_argument('application', help='Application OD') | |
parser.add_argument('property', choices=['link', 'login', 'password'], help='Property to change') | |
parser.add_argument('value', help='New value of the property') | |
main(parser.parse_args()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment