MCPcopy Index your code
hub / github.com/geekcomputers/Python / main

Function main

google.py:18–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17
18def main():
19 if len(sys.argv) > 1:
20 keyword = " ".join(sys.argv[1:])
21 else:
22 # if no keyword is entered, the script would search for the keyword
23 # copied in the clipboard
24 keyword = pyperclip.paste()
25
26 res = requests.get("http://google.com/search?q=" + keyword)
27 res.raise_for_status()
28 soup = bs4.BeautifulSoup(res.text)
29 linkElems = soup.select(".r a")
30 numOpen = min(5, len(linkElems))
31
32 for i in range(numOpen):
33 webbrowser.open("http://google.com" + linkElems[i].get("href"))
34
35
36if __name__ == "__main__":

Callers 1

google.pyFile · 0.70

Calls 2

pasteMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected