Sinisterly
ALLINTEXT Python Google Search Tool - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: ALLINTEXT Python Google Search Tool (/Thread-ALLINTEXT-Python-Google-Search-Tool)



ALLINTEXT Python Google Search Tool - Stocking - 03-10-2014

This was made at the request of Sabi.

Basically, you just type what you want and it searches Google with 'allintext: ' before your search. This finds everything within the text of your search.

The imports needed would be webbrowser, and that is all.
Code:
import webbrowser

o = webbrowser.open

We defined 'o' so we can easily use the webbrowser open import instead of typing webbrowser.open.

Code:
url_1 = 'https://www.google.com/search?q=allintext%3A+'
url_2 = '&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox&channel=sb'

Those are the two parts of the url that make up this tool, basically we type what we want and it brings it up. The third part is the input for what should be searched.

Code:
def search():
    x = input('ALLINTEXT: ')
    s = x.replace(' ','%20')
    o(url_1 + s + url_2)
    loop()

This is our search, it prompts the user for what is wanted, replaces spacing with %20 and then opens the URL.

Code:
def loop():
    search()

This is just the loop and is quite useless to most, but causes it to loop infinitely.

Code:
search()

This just tells the program to start with the search definition.

Spoiler:
Code:
import webbrowser

o = webbrowser.open
url_1 = 'https://www.google.com/search?q=allintext%3A+'
url_2 = '&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox&channel=sb'

def search():
    x = input('ALLINTEXT: ')
    s = x.replace(' ','%20')
    o(url_1 + s + url_2)
    loop()

def loop():
    search()

search()



RE: ALLINTEXT Python Google Search Tool - Neko - 03-10-2014

I'm lazy, and If you want to know why it's useful contact me on skype.