Advertisement
Thelorgoreng

gis code( chatango bot )

Sep 2nd, 2015
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. elif cmd == "gis" and len(args) > 0: ##new by thelorgorenk
  2.             try:
  3.                 search = args.split()
  4.                 import urllib.request
  5.                 with urllib.request.urlopen("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s" % "+".join(search)) as url:
  6.                     udict = url.read().decode()
  7.                 a = re.finditer('"unescapedUrl":"(.+?)","url":"', udict)
  8.                 matches = []
  9.                 for match in a:
  10.                     match = str(match.group(1))
  11.                     matches.append(match)
  12.                
  13.                 link = random.choice(matches)
  14.                 try:
  15.                     link = link.replace("https", "http")
  16.                 except:
  17.                     print("Random choice isn't SSL.")
  18.                 if args: room.message("%s , <f x1233FFFF='1'>I <f x12F00='1'>Found: %s" % (sntonick(user.name), link), True)
  19.             except Exception as e:
  20.                 room.message("%s Sorry i can't Find it %s :|" % (sntonick(user.name), args), True)
  21.                 print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement