code: def msgurls(msg, urlidx=1):
      
      # Written as a generator so I can easily choose only
      # one subpart in the future (e.g., for
      # multipart/alternative).  Actually, I might even add
      # a browser for the message structure?
      enc = get_charset(msg)
      if msg.is_multipart():
          for part in msg.get_payload():
              for chunk in msgurls(part, urlidx):
                  urlidx += 1
                  yield chunk
      elif msg.get_content_type() == "text/plain":
          decoded = decode_msg(msg, enc)
          for chunk in extracturls(decoded):
              urlidx += 1
              yield chunk
      elif msg.get_content_type() == "text/html":
          decoded = decode_msg(msg, enc)
          for chunk in extracthtmlurls(decoded):
              urlidx += 1
              yield chunk
docs: Main entry function for urlscan.py