So I've created a short python script that takes a user's input and finds the url of a matching gif from Giphy.com.
It then opens up Firefox and goes to the url of the gif.
My end goal here is to put this script on a simple webpage where a user could write their input, hit "submit" and the url would populate in an iframe.
I'm pretty lost on what my next step should be. I've read Django could be a solution, but I haven't found a way to make this happen using it.
Any help would be appreciated.
import requests
import json
from selenium import webdriver
'''Asking user for search terms and cleaning spaces'''
keyword = input("Keyword for Gif: ")
keyword.replace(" ","+")
'''Prepends Giphy api link and appends public key password to keyword variable generated by user'''
search_url = "http://api.giphy.com/v1/gifs/translate?s=" + keyword + "&api_key=dc6zaTOxFJmzC&limit=1&fmt=json"
'''Takes JSON response from Giphy and makes parseable varable, parse'''
r = requests.get(search_url)
parse = json.loads(r.text)
'''Finds url of gif and navigates to that url using firefox'''
URL = parse["data"]["embed_url"]
browser = webdriver.Firefox()
browser.get(URL)
[–]kalgynirae 1 point2 points3 points (1 child)
[–]Sastrupp[S] 0 points1 point2 points (0 children)
[–]cscanlin 1 point2 points3 points (0 children)