Advertisement
Alexquickdraw

Bing image search for chatango bots.

Dec 31st, 2016
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #Bing image scrape method for ch.py bots
  2. #Using Python 3.4
  3. #By Hardware
  4.      
  5.   elif used_prefix and cmd == "bing":
  6.              images = []
  7.              new = []
  8.              if not args: return room.message("You need a search keyword..")
  9.              url = requests.get("https://www.bing.com/images/search?q="+args)
  10.              soup = BeautifulSoup(url.content, "html.parser")
  11.              for img in soup.findAll('img'):
  12.                  images.append(img.get('src'))
  13.              for i in images[2:]:
  14.                  if (".jpg" or ".png" or "gif") in str(i):
  15.                      new.append(i)
  16.                  else: new.append(str(i).replace("=1.1", "=1.1.jpg"))
  17.              room.message("\r \r \r"+"\r".join(new[0:3]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement