diff --git a/ImportanceChecker/ImportanceChecker.py b/ImportanceChecker/ImportanceChecker.py new file mode 100644 index 0000000..be43ec0 --- /dev/null +++ b/ImportanceChecker/ImportanceChecker.py @@ -0,0 +1,36 @@ +try: + from googlesearch import search +except ImportError: + print("No module named 'google' found.") + + +def ImportanceChecker(query, stoplevel=10, pauselevel=1): + """ + Checks 'importance' by analyzing google search results for a person/topic and + finding if they have a wikipedia page among the top results. Number of search + results required is automatically set to 10. + """ + + #urlgenerator runs relatively slowly to prevent google from blocking user IP + urlgenerator = search(query, stop=stoplevel, pause=pauselevel) + for _ in range(stoplevel): + url = next(urlgenerator) + if 'wikipedia' in url: + return True + return False + + +def main(): + print("Who do you want to be searched? ", end="") + + query = input() + + important = ImportanceChecker(query) + + if (important): + print(f"{query} is important!") + else: + print(f"{query} isn't that important.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ImportanceChecker/README.md b/ImportanceChecker/README.md new file mode 100644 index 0000000..de7be9f --- /dev/null +++ b/ImportanceChecker/README.md @@ -0,0 +1,22 @@ +#Importance Checker + +A simple program to check for a person or topic's "importance" by checking whether the search value's possible Wikipedia page appears in the top *x* Google search results, where *x* is set to 10 by default. + +##Instructions + +Type these commands in the terminal: + +`pip install beautifulsoup` + +`pip install google` + + +Now type: + +`ImportanceChecker.py` + +The program will run, and test a user-inputted value if in *main*. Use `import ImportanceChecker` to use it in your python project. + + +###Notes: +* *ImportanceChecker* runs relatively slow to help prevent Google from blocking the user's IP address. One can modify the time delay in between requests to speed the function up by changing the third parameter to something other than its default, *1*. \ No newline at end of file diff --git a/ImportanceChecker/requirements.txt b/ImportanceChecker/requirements.txt new file mode 100644 index 0000000..8bec0b2 --- /dev/null +++ b/ImportanceChecker/requirements.txt @@ -0,0 +1,2 @@ +beautifulsoup4 +google \ No newline at end of file diff --git a/README.md b/README.md index 9cb305a..560ffce 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ So far, the following projects have been integrated to this repo: |[HTML Table to List](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/HTML_Table_to_List) | [Nitish Srivastava](https://github.com/nitish-iiitd)| |[Image circle formatter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Image-Circulator) |[Berk Gureken](https://github.com/bureken) | |[Image To PDF](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/images2pdf)|[msaoudallah](https://github.com/msaoudallah)| +|[Importance Checker](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/ImportanceChecker)|[natesabrown](https://github.com/natesabrown)| |[Instadp Web Scrapper](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/InstadpShower)|[Psychiquest](https://github.com/psychiquest)| |[Keylogger](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Keylogger) |[Preet Mishra](https://github.com/preetmishra) | |[Minecraft Server in background](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Minecraft_server_in_background)|[Max von Forell](https://github.com/mvforell)|