#NEWLINE# def get_checkbox_choices( self , doc ) : #NEWLINE# #INDENT# '\n        parse the doc (a string), and return a dictionary of\n        name->text. The checkboxes should be of the following format:\n        <input type="checkbox" name="something">text</input>\n        ' #NEWLINE# from pyquery import PyQuery as pq #NEWLINE# d = pq ( doc , parser = 'html' ) #NEWLINE# inputs = d ( 'input' ) #NEWLINE# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for i in range ( 0 , len ( doc ) ) : #NEWLINE# #INDENT# if ( inputs . eq ( i ) . attr . type == 'checkbox' ) : #NEWLINE# #INDENT# choice = str ( inputs . eq ( i ) ) . split ( '>' ) [ 1 ] . lstrip ( ) #NEWLINE# result [ choice ] = inputs . eq ( i ) . attr . name #NEWLINE# #UNINDENT# #UNINDENT# return result