def rdoc(num_elements=1000):
 tag_names = ['p', 'div', 'span', 'i', 'b', 'script', 'table']
 elements = []
 for i in range(num_elements):
  choice = random.randint(0, 3)
  if (choice == 0):
   tag_name = random.choice(tag_names)
   elements.append(('<%s>' % tag_name))
  elif (choice == 1):
   elements.append(rsentence(random.randint(1, 4)))
  elif (choice == 2):
   tag_name = random.choice(tag_names)
   elements.append(('</%s>' % tag_name))
 return (('<html>' + '\n'.join(elements)) + '</html>')

def rdoc ( num_elements = 1000 ) : tag_names = [ 'p' , 'div' , 'span' , 'i' , 'b' , 'script' , 'table' ] elements = [ ] for i in range ( num_elements ) : choice = random . randint ( 0 , 3 ) if ( choice == 0 ) : tag_name = random . choice ( tag_names ) elements . append ( ( '<%s>' % tag_name ) ) elif ( choice == 1 ) : elements . append ( rsentence ( random . randint ( 1 , 4 ) ) ) elif ( choice == 2 ) : tag_name = random . choice ( tag_names ) elements . append ( ( '</%s>' % tag_name ) ) return ( ( '<html>' + '\n' . join ( elements ) ) + '</html>' )
randomly generate an invalid html document .