python - Trouble using webbrowser module to open a Google search -
Hey, I'm currently trying to follow a simple Google search with Python script, I'm following the code line from the line. The issue in the attached video is that my code will open a new tab and bring me to the Google homepage but it does not do the actual search. The odd thing is that the search query appears in the URL but it's more to accept my search does not. Any help would be appreciated, thank you.
Code for Python script
import webbrover new = 2 tabUrl = "http://google.com/?#q="; Term = raw_input ("Enter search query:"); Webbrowser.open (tabUrl + period, new = new);
Here's the problem: when you enter a word as a query string , "Python"), your code works just fine. However, if you want to find more than one word ("Python Webbuster Module"), then you have a problem. Since there are spaces in the search term, the URL will be empty space. Some browsers and operating systems, such as Firefox 28 (My current setup) at Ubuntu 14.04, will handle those places properly, although others may not use any of the degrading characters like Space, Comma, Epprophes etc. -Scape equivalents such as % 20
change for the place.
Urlib import quote import webbrowser new = 2 # Not really necessary, most modern browsers may default on base_url = "http://www.google.com/?#q= "Query = raw_input (" Please enter your search query: ") Final_url = base_url + quote (query) webbrowser.open (final_url, new = new)