I'm creating this automation script in python that uses a dictionary to open a browser and when using webbrowser module to open a parsed dictionary, I keep getting a key error. Here is the code:
import webbrowser, sys, requests
ptcl = 'https://'
tail = '.com/'
context_dict =
{
'fb': ptcl + 'facebook' + tail,
'ig': ptcl + 'instagram' + tail,
'google': ptcl + 'google' + tail,
'kat': ptcl + 'kat.cr',
'mail': ptcl + 'gmail' + tail,
'utube': ptcl + 'youtube' + tail,
}
def open_page(page):
webbrowser.open(context_dict[page])
def get_args():
if len(sys.argv) > 1:
for i in sys.argv[1:]:
page = context_dict[i.replace(',', '')]
open_page(page)
if __name__ == '__main__':
get_args()
Here is an example of when trying to access fb from the cmd sample fb run