Created
January 10, 2024 23:36
-
-
Save djamseed/751da3f4595d20f98dcf451f4d58bebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import webbrowser | |
| def google_search(query): | |
| base_url = "https://www.google.com/search?q=" | |
| query_string = query.replace(" ", "+") | |
| # show results from the sites below | |
| sites = ["dev.to", "github.com", "medium.com", "stackoverflow.com", "youtube.com"] | |
| site_string = " OR ".join(["site:" + site for site in sites]) | |
| query_string += " (" + site_string + ")" | |
| search_url = base_url + query_string | |
| webbrowser.open_new_tab(search_url) | |
| print(search_url) | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 2: | |
| print("Usage: search <query>") | |
| sys.exit(1) | |
| query = " ".join(sys.argv[1:]) | |
| google_search(query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment