Python Forum
Take a question in a text doc and automatically googling it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Take a question in a text doc and automatically googling it
#1
Hello and thanks for reading. Here is what I have so far:

from urllib.request import urlretrieve
from urllib.parse import urlencode
mydict = {'q': 'whee! Stanford!!!', 'something': 'else'}
qstr = urlencode(mydict)
# str resolves to: 'q=whee%21+Stanford%21%21%21&something=else'
thing = urlretrieve("https://www.google.com/search?" + qstr)
I have a text document (named OCR.txt specifically). I want to take the question that is in it (that is the only
thing inside of it) and then encode it to the google search url. (The random stuff in mydict is just a placeholder).

Also, I then do not know how to have it open chrome and paste the URL into the search to open it automatically.

I found out that the Unix binary, located at /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome, can open URLs without launching a new browser instance. I just do not know how to make it open.

Any help is massively appreciated, I am a beginner and am learning the ropes.

Thanks!
Reply


Messages In This Thread
Take a question in a text doc and automatically googling it - by DevinGP - Dec-19-2017, 07:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  selenium wait for text question Larz60+ 3 2,666 Oct-25-2021, 09:50 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020