Created
July 6, 2014 06:38
-
-
Save ColtonPhillips/ffe0874b9a785953dd20 to your computer and use it in GitHub Desktop.
What if you could turn an arbitrary text into a google search?
This file contains 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
#TODO: what about a string with < or > ? what about with </a> ? etc | |
#https://www.google.ca/#q=hat+%22stand+man+'dog'+%22 | |
# hat "stand man 'dog' " | |
my_string = "hat \"stand man 'dog' \"" | |
print("String:") | |
print(my_string) | |
google_string = my_string.replace('"',"%22").replace(" ","%20") | |
print("Google String:") | |
print(google_string) | |
google_search = "https://www.google.com/search?q=" + google_string | |
print("Google Search:") | |
print(google_search) | |
my_http_string = '<div>\n\t<a href="' + google_search + '" target="_blank" >\n\t\t' + my_string + '\n\t</a>\n</div>' | |
print("HTTP:") | |
print(my_http_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment