Script to search google - problem with multiple quotations

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
iAccidentally
Posts: 3
Joined: 30 Jan 2012 19:38

Script to search google - problem with multiple quotations

#1 Post by iAccidentally » 30 Jan 2012 22:03

Hello,

I have a fairly simple question to ask but I haven't been able to figure this problem out. I'm working on a script that calls up a browser and performs advanced google searches which have multiple double quotes in them. The way I'm doing this is by using google's search syntax directly in the URL which I send to chrome. The google search is supposed to look something like this:

intitle:"hello there" inurl:"some other term"

At first I tried the following code:

Code: Select all

start chrome.exe  http://www.google.com/search?q=intext:"hello there" inurl:"some other term"
(which works just fine if I copy paste it into the url bar)

This brought up the google search results page, but the quotes got removed and only the first search term made it through, this is what the search ended up looking like:

intext:hello there

Then I tried this code:

Code: Select all

start chrome.exe http://www.google.com/search?q=intext:"hello there"%%20inurl:"some other term"

The google search result ended up being:

intext:hello there inurl:some other term


So I think I'm halfway there, but the quotes got removed from the search. I had to double the % symbol in the URL to escape it, otherwise there would be no space between the two search terms. But I'm not sure how to make the quotation marks show up in the query, they seem to disappear from the URL when it gets sent to chrome.

I thought I should add that I'm using windows 7 not xp, I don't know if this would make much of a difference.

Any help would be greatly appreciated. Thank you.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Script to search google - problem with multiple quotatio

#2 Post by Squashman » 31 Jan 2012 07:29

Well %22 is going to be the Quote. Can't seem to get it to work correctly though.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Script to search google - problem with multiple quotatio

#3 Post by Squashman » 31 Jan 2012 07:35

This seems to work

Code: Select all

start "" "chrome.exe" http://www.google.com/search?q=intext:%%22hello+there%%22+inurl:%%22some+other+term%%22

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Script to search google - problem with multiple quotatio

#4 Post by Ed Dyreen » 31 Jan 2012 08:10

'
This seems to work (from commandline)

Code: Select all

start firefox.exe http://www.google.com/search?q=intext:%22hello+there%22%26inurl:%22google%22

Code: Select all

intext:"hello there"&inurl:"google"

Code: Select all

Hello There! - Google Chrome Extensions - Google Code
code.google.com/chrome/extensions/docs.html
Hello There! ... Hello There! This documentation tells you how to write extensions and packaged apps for the Google Chrome browser. Because extensions ...
[edit] Squashman was a little quicker though :)

iAccidentally
Posts: 3
Joined: 30 Jan 2012 19:38

Re: Script to search google - problem with multiple quotatio

#5 Post by iAccidentally » 31 Jan 2012 13:17

Thank you both very much for the help! Works perfectly now :)

I've simplified it to the following and it still works:

Code: Select all

start chrome.exe http://www.google.com/search?q=intext:%%22hello+there%%22+inurl:%%22some+other+term%%22


Good call with using %22 in the url, didn't realize that I could put quotes in that way.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Script to search google - problem with multiple quotatio

#6 Post by Squashman » 31 Jan 2012 13:26

iAccidentally wrote:Thank you both very much for the help! Works perfectly now :)

I've simplified it to the following and it still works:

Code: Select all

start chrome.exe http://www.google.com/search?q=intext:%%22hello+there%%22+inurl:%%22some+other+term%%22


Good call with using %22 in the url, didn't realize that I could put quotes in that way.

Well you were putting in a Space in that way so anything is possible. You could substitute the colon with a %3A I believe as well.

I have always felt it was best coding practice to always use the EMPTY quotes when using the start command and I always put paths and file names in quotes regardless if they have spaces. It is just a good habit to learn.

iAccidentally
Posts: 3
Joined: 30 Jan 2012 19:38

Re: Script to search google - problem with multiple quotatio

#7 Post by iAccidentally » 31 Jan 2012 13:36

Well you were putting in a Space in that way so anything is possible. You could substitute the colon with a %3A I believe as well.

I have always felt it was best coding practice to always use the EMPTY quotes when using the start command and I always put paths and file names in quotes regardless if they have spaces. It is just a good habit to learn.


Thanks for clarifying Squashman. I'll keep all that in mind next time.

Glad to be part of such a helpful forum :)

Post Reply