Created
June 29, 2012 17:15
-
-
Save sash13/3019324 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def input_parse(base): | |
| query = 'input ' | |
| input_parts = {} | |
| sta=0 | |
| while sta !=-1: | |
| sta=base[1:].find(query) | |
| if sta == -1: | |
| break | |
| sta_len = sta+len(query) | |
| end = base[sta_len:].find('>')+sta_len | |
| stroka = base[sta_len:end] | |
| name = stroka.split('name="')[1].split('"')[0] | |
| try: | |
| value = stroka.split('value="')[1].split('"')[0] | |
| except: | |
| value = '' | |
| input_parts[name]=value | |
| base=base[end:] | |
| return input_parts | |
| def input_parse(base): | |
| input_list = {} | |
| htmltree = lxml.html.fromstring(base) | |
| for input_q in htmltree.xpath('//input'): | |
| try: | |
| input_list[input_q.attrib['name']]=input_q.attrib['value'] | |
| except: | |
| pass | |
| return input_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment