-
Notifications
You must be signed in to change notification settings - Fork 1
/
srch
143 lines (116 loc) · 3.7 KB
/
srch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import webbrowser
pm = sys.argv[1]
input = sys.argv[2:]
args = (' '.join(input))
def usage():
print("srch - search from the commandline \n")
print("python srch <platform> <query> \n")
print('''platforms to search for
wiki Search Wikipedia for query
so Search StackOverflow for query
g Search Google for query
r Search Reddit for query
gh Search GitHub for query
devto Search dev.to for query
m Search Medium for query
yt Search Youtube for query
tw Search Twitter for query
gfg Search GeeksforGeeks for query
stx Search Stackexchange for query
q Search quora for query
url Search for url
fcc Search freecodecamp for query
shell Search explainshell for query
mdn Search MDN Web Docs for query
Usage:
$ python srch help # help menu
$ python srch g what is github commit signing\n''' )
def wiki(args):
wikipedia = 'https://en.wikipedia.org/wiki/' + str(args)
webbrowser.open(wikipedia)
def stackoverflow(args):
stackoverflow = 'https://stackoverflow.com/search?q=' + str(args)
webbrowser.open(stackoverflow)
def google(args):
google = 'https://www.google.com/search?q=' + str(args)
webbrowser.open(google)
def reddit(args):
reddit = 'https://www.reddit.com/search/?q=' + str(args)
webbrowser.open(reddit)
def github(args):
github = 'https://github.com/search?q=' + str(args)
webbrowser.open(github)
def devto(args):
devto = 'https://dev.to/search?q=' + str(args)
webbrowser.open(devto)
def medium(args):
medium = 'https://medium.com/search?q=' + str(args)
webbrowser.open(medium)
def youtube(args):
youtube = 'https://www.youtube.com/results?search_query=' + str(args)
webbrowser.open(youtube)
def twitter(args):
twitter = 'https://twitter.com/search?q=' + str(args)
webbrowser.open(twitter)
def geeksforgeeks(args):
geeksforgeeks = 'https://www.geeksforgeeks.org/search/?q=' + str(args)
webbrowser.open(geeksforgeeks)
def stackexchange(args):
stackexchange = 'https://stackexchange.com/search?q=' + str(args)
webbrowser.open(stackexchange)
def quora(args):
quora = 'https://www.quora.com/search?q=' + str(args)
webbrowser.open(quora)
def url(args):
uri ='https://' + str(args)
webbrowser.open(uri)
def freecodecamp(args):
freecodecamp = 'https://www.freecodecamp.org/news/search/?query=' + str(args)
webbrowser.open(freecodecamp)
def explainshell(args):
explainshell = 'https://explainshell.com/explain?cmd=' + str(args)
webbrowser.open(explainshell)
def mdn(args):
mozilladocs = 'https://developer.mozilla.org/en-US/search?q=' + str(args)
webbrowser.open(mozilladocs)
if pm == "--h" or pm == "--help" or pm == "-h" or pm == "-help" or pm == "help" or pm == "h":
usage()
elif pm == "wiki":
wiki(args)
elif pm == "so":
stackoverflow(args)
elif pm == "g":
google(args)
elif pm == "r":
reddit(args)
elif pm == "gh":
github(args)
elif pm =="devto":
devto(args)
elif pm == "m":
medium(args)
elif pm == "yt":
youtube(args)
elif pm == "tw":
twitter(args)
elif pm == "gfg":
geeksforgeeks(args)
elif pm == "stx":
stackexchange(args)
elif pm == "q":
quora(args)
elif pm == "url":
url(args)
elif pm == "fcc":
freecodecamp(args)
elif pm == "shell":
explainshell(args)
elif pm == "mdn":
mdn(args)
else:
print('Invalid command...\n\n')
usage()
sys.exit()