Page 1 of 1

Script to search google - problem with multiple quotations

Posted: 30 Jan 2012 22:03
by iAccidentally
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.

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 07:29
by Squashman
Well %22 is going to be the Quote. Can't seem to get it to work correctly though.

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 07:35
by Squashman
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

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 08:10
by Ed Dyreen
'
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 :)

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 13:17
by iAccidentally
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.

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 13:26
by Squashman
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.

Re: Script to search google - problem with multiple quotatio

Posted: 31 Jan 2012 13:36
by iAccidentally
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 :)