Reputation: 17
Here is the code I have, it works fine, but how could I make it that there is a new variable that is equal to the Image URL of the GIF so that the user can get the Source URL of the GIF?
import requests
url = "https://giphy.p.rapidapi.com/v1/gifs/search"
searchtag = input()
querystring = {"api_key":"secret_key","q":searchtag,"limit":"1","offset":"0","rating":"pg-13"}
headers = {
'x-rapidapi-key': "4005b98f9bmsh977c629b89034a7p19b52fjsn22b7fb5ce3bb",
'x-rapidapi-host': "giphy.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
Upvotes: 0
Views: 1350
Reputation: 11
First off you should probably remove your api key for your own personal safety . I'd recommend looking into environmental files for storing private information that doesn't belong in a database. Second off to answer your question you could just declare the url as a variable if you're feeling ever so inclined, here:
import requests
url = "https://giphy.p.rapidapi.com/v1/gifs/search"
searchtag = input()
querystring = {"api_key":process.env.APIKEY,"q":searchtag,"limit":"1","offset":"0","rating":"pg-13"}
headers = {
'x-rapidapi-key': "4005b98f9bmsh977c629b89034a7p19b52fjsn22b7fb5ce3bb",
'x-rapidapi-host': "giphy.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
gifurl = response.text
print(gifurl)
Upvotes: 0