Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- from HTMLParser import HTMLParser
- from htmlentitydefs import name2codepoint
- correctForm = False;
- class MyHTMLParser(HTMLParser):
- def handle_endtag(self, tag):
- global correctForm
- if correctForm == True: # Form closing tag
- if tag == "form":
- sys.exit(0);
- elif tag == "select":
- print "&"
- def handle_starttag(self, tag, attrs):
- global correctForm
- global requireChecked
- global isCheckBox
- if sys.argv[1] == "": # Process any form data?
- correctForm = True;
- if correctForm == False: # Verify if this is the form we want data from
- if tag == "form":
- for attr in attrs:
- if attr[0] == "id":
- if attr[1] == sys.argv[1]:
- correctForm = True;
- else:
- if tag == "select":
- for attr in attrs:
- if attr[0] == "name":
- print attr[1]
- print "="
- elif tag == "option":
- for attr in attrs:
- if attr[0] == "selected":
- for attr in attrs:
- if attr[0] == "value":
- print attr[1]
- elif tag == "input":
- requireChecked = False;
- for attr in attrs:
- if attr[0] == "type" and attr[1] == "radio":
- requireChecked = True;
- elif attr[0] == "type" and attr[1] == "checkbox":
- requireChecked = True;
- elif attr[0] == "disabled" and attr[1] == "true":
- return;
- if requireChecked == True:
- for attr in attrs:
- if attr[0] == "checked":
- requireChecked = False;
- if requireChecked == False:
- for attr in attrs:
- if attr[0] == "name":
- print attr[1]
- print "="
- for attr in attrs:
- if attr[0] == "value":
- print attr[1]
- print "&"
- parser = MyHTMLParser()
- parser.feed( sys.stdin.read() )
Advertisement
Add Comment
Please, Sign In to add comment