def demo__google_result_open_in_new_tab(raw_text, content_mime):
 def hexlify_to_json(ascii_str):
  _buff = ''
  for char in ascii_str:
   if (char in '\'"<>&='):
    _buff += ('\\x' + hex(ord(char))[2:])
   else:
    _buff += char
  _buff = _buff.replace('\\', '\\\\')
  _buff = _buff.replace('/', '\\/')
  return _buff
 if (content_mime == 'application/json'):
  raw_text = raw_text.replace(hexlify_to_json('<h3 class="r"><a href="'), hexlify_to_json('<h3 class="r"><a target="_blank" href="'))
  raw_text = raw_text.replace(hexlify_to_json('<h3 class="r"><a class="l" href="'), hexlify_to_json('<h3 class="r"><a target="_blank" class="l" href="'))
 else:
  raw_text = raw_text.replace('<h3 class="r"><a href="', '<h3 class="r"><a target="_blank" href="')
  raw_text = raw_text.replace('<h3 class="r"><a class="l" href="', '<h3 class="r"><a target="_blank" class="l" href="')
 return raw_text

def demo__google_result_open_in_new_tab ( raw_text , content_mime ) : def hexlify_to_json ( ascii_str ) : _buff = '' for char in ascii_str : if ( char in '\'"<>&=' ) : _buff += ( '\\x' + hex ( ord ( char ) ) [ 2 : ] ) else : _buff += char _buff = _buff . replace ( '\\' , '\\\\' ) _buff = _buff . replace ( '/' , '\\/' ) return _buff if ( content_mime == 'application/json' ) : raw_text = raw_text . replace ( hexlify_to_json ( '<h3 class="r"><a href="' ) , hexlify_to_json ( '<h3 class="r"><a target="_blank" href="' ) ) raw_text = raw_text . replace ( hexlify_to_json ( '<h3 class="r"><a class="l" href="' ) , hexlify_to_json ( '<h3 class="r"><a target="_blank" class="l" href="' ) ) else : raw_text = raw_text . replace ( '<h3 class="r"><a href="' , '<h3 class="r"><a target="_blank" href="' ) raw_text = raw_text . replace ( '<h3 class="r"><a class="l" href="' , '<h3 class="r"><a target="_blank" class="l" href="' ) return raw_text
force google searchs result to open in new tab .