# RapidAPI page https://rapidapi.com/gorlavasudeva/api/mcu-comics-and-characters/
# Begin Rapid API Code
import requests
url = "https://mcu-comics-and-characters.p.rapidapi.com/mcu/comics"
headers = {
"X-RapidAPI-Key": "40507ace9fmshcdcac9ccdd404c3p1d6853jsn21cc92ac2d5e",
"X-RapidAPI-Host": "mcu-comics-and-characters.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print("Hello, welcome to our database, what MCU comic would you like to search for?")
myUserInput = input().lower() # doesn't matter whether or not user input is capitalized or not
# myUserInput = "Agents of S.H.I.E.L.D.: The Chase" #set default variable
myCounter = 0
import re # importing regex
def convert_into_uppercase(a): # capitalizes first letter of each word
return a.group(1) + a.group(2).upper()
s = myUserInput
result = re.sub("(^|\s)(\S)", convert_into_uppercase, s)
mySearchResult = "You searched for: '" + str(result) + "'\n"+ "\t" + "Learn more at this link: "
movies = response.json()
movies.pop(0)
r = myUserInput
r1 = r.replace(".", "")
r2 = r1.replace("-", "")
r3 = r2.replace(":", "")
r4 = r3.replace("!", "")
r5 = r4.replace(" ", " ")
print(r5)
# for movie in movies: #loop through my menu
# # print(movie["title"])
# # print(movie["link"])
# myLowercase = movie["title"].lower()
# if r4 == myLowercase:
# #if the user input matches item in list, regardless of capitalization or punctuation
# print(mySearchResult + movie["link"]) #then prints the key and value
# break #stop looping when you get result
# else:
# myCounter += 1 #increase through list by increment of 1
# if myCounter == 70: # if loop 70 times, it means we don't have the item in the api
# print("Sorry, we don't have '" + str(myUserInput) + "' in our database :(. Try searching a different comic!") # print error if message isn't in list
import requests
url = "https://mcu-comics-and-characters.p.rapidapi.com/mcu/comics"
headers = {
"X-RapidAPI-Key": "40507ace9fmshcdcac9ccdd404c3p1d6853jsn21cc92ac2d5e",
"X-RapidAPI-Host": "mcu-comics-and-characters.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
movies = response.json()
movies.pop(0)
numberOfElements = len(movies)
print(numberOfElements)
punc = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
my_str = input()
no_punct = ""
for char in my_str:
if char not in punc:
no_punct = no_punct + char
print(no_punct)
# s1=s.replace(".","")
# print (s1)
# RapidAPI page https://rapidapi.com/gorlavasudeva/api/mcu-comics-and-characters/
# Begin Rapid API Code
import requests
url = "https://mcu-comics-and-characters.p.rapidapi.com/mcu/comics"
headers = {
"X-RapidAPI-Key": "40507ace9fmshcdcac9ccdd404c3p1d6853jsn21cc92ac2d5e",
"X-RapidAPI-Host": "mcu-comics-and-characters.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print("Hello, welcome to our database, what MCU comic would you like to search for?")
myUserInput = input().lower() # doesn't matter whether or not user input is capitalized or not
# myUserInput = "Agents of S.H.I.E.L.D.: The Chase" #set default variable
myCounter = 0
import re # importing regex
def convert_into_uppercase(a): # capitalizes first letter of each word
return a.group(1) + a.group(2).upper()
s = myUserInput
result = re.sub("(^|\s)(\S)", convert_into_uppercase, s)
mySearchResult = "You searched for: '" + str(result) + "'\n"+ "\t" + "Learn more at this link: "
movies = response.json()
movies.pop(0)
for movie in movies: #loop through my menu
if movie["title"].lower() == myUserInput:
#if the user input matches item in list, regardless of capitalization or punctuation
print(mySearchResult + movie["link"]) #then prints the key and value
break #stop looping when you get result
else:
myCounter += 1 #increase through list by increment of 1
if myCounter == 70: # if loop 70 times, it means we don't have the item in the api
print("Sorry, we don't have '" + str(myUserInput) + "' in our database :(. Try searching a different comic!") # print error if message isn't in list
# RapidAPI page https://rapidapi.com/gorlavasudeva/api/mcu-comics-and-characters/
# Begin Rapid API Code
import requests
url = "https://mcu-comics-and-characters.p.rapidapi.com/mcu/comics"
headers = {
"X-RapidAPI-Key": "40507ace9fmshcdcac9ccdd404c3p1d6853jsn21cc92ac2d5e",
"X-RapidAPI-Host": "mcu-comics-and-characters.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print("Hello, welcome to our database, what MCU comic would you like to search for?")
myUserInput = input()# doesn't matter whether or not user input is capitalized or not
# myUserInput = "Agents of S.H.I.E.L.D.: The Chase" #set default variable
movies = response.json()
movies.pop(0)
for movie in movies: #loop through my menu
if movie["title"].lower() == myUserInput.lower():
#if the user input matches item in list, regardless of capitalization or punctuation
print(mySearchResult + movie["link"]) #then prints the key and value
break #stop looping when you get result
else:
myCounter += 1 #increase through list by increment of 1
if myCounter == 70: # if loop 70 times, it means we don't have the item in the api
print("Sorry, we don't have '" + str(myUserInput) + "' in our database :(. Try searching a different comic!") # print error if message isn't in list