How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks. Do you have a similar answer for accessing Google Images via their URL?
First off, thanks for the cup of coffee. I'm drinking it now as I type in this answer, actually, an almond milk chai from one of my favorite local coffee shops, Atlas Purveyors. Goodness, for sure.
In terms of what you ask, it's actually pretty easy to reverse engineer just about any search site because they use what's called a "GET method" of sending the search parameter to the system after you type in what you seek. That's really what I tapped into on the Amazon search links that you have already read.
I've already written about Google Image Search more than once here, but I've never considered the question of building pre-defined searches as simple text links. Still, easily done, and the place to start is to read my previous article on adding a Google Image Search box to your page.
Armed with that information, let's jump in!
Go to Google Image Search and search for, say, "Michelle Obama". Your search results link in your browser will look like this:
Ugh, that's really ugly, with lots going on. But, hmmm... what if I just deleted everything from the URL other than the q="michelle+obama", so the URL looks like this:
This sort of live URL hacking is essential to these sort of reverse engineering tasks, and this particular one reveals that, well, this isn't sufficient for the URL to work: the results are a regular Google search, not an image search. Conclusion: one of the missing parameters tells Google that you're doing an image search, not a regular one, and we need to restore it for the link to work.
Again, I'll edit directly in the Web browser address bar, reducing the search down to the pattern plus the two parameters that seem to be related to the type of search:
That works! But I'm curious, so my last hack attempt is to simply remove the "source=" parameter entirely, producing the even shorter URL:
Not sure what "tbm" stands for, but that's the key attribute, and if you give it the value "isch" (image search, no doubt) the link will work fine.
Now to build the search pattern itself. If it's just a word or couple of words, that's easy, simply replace "michelle+obama" with what you'd like to specify. If it's a more complex search with punctuation marks or other odd characters, my recommendation would be to actually do a search, then look closely at the resultant URL to see how the punctuation (etc) has been encoded.
Then you can do things like this: Look for images of disgraced pro biker Lance Armstrong or, better yet, images of news about Lance Armstrong that doesn't mention doping.
How did I do those? Pretty straightforward, here's the HTML for those:
Then you can do things like this: Look for images of disgraced pro biker <a href="http://www.google.com/search?q=lance+armstrong&tbm=isch" target="_blank">Lance Armstrong</a> or, better yet, images of <a href="http://www.google.com/search?q=%22lance+armstrong%22+news+-doping&tbm=isch" target="_blank">news about Lance Armstrong that doesn't mention doping</a>.
The only subtlety is that since I'm quoting the URL for properly formed HTML, I can't just use double quotes within the URL itself. Easy enough, simple replace each embedded " symbol with a %22. Easy.
Hope you find this helpful and sufficiently informative to get you started!
✔ How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....✔ Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...✔ Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....✔ How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...✔ How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
I do have a comment, now that you mention it!
Check This Out Too...
Look for Answers
All Our Categories
Apple iPad Help
Articles and Reviews
Auctions and Online Shopping
Blogs and Blogging
Building Web Site Traffic
Business and Management
Computer and Internet Basics
d) None of the Above
Google Gmail Help
Google Plus Help
Industry News and Trade Shows
iPhone and Cell Phone Help
iPod, Sony PSP and MP3 Player Help
Kindle Fire Help
Mac OS X Help
Pay Per Click (PPC) Advertising
Search Engine Optimization (SEO)
Shell Script Programming
Tech Support Video Help
The Writing Business
Twitter, LinkedIn and Social Network Help
Unix and Linux Help
Video Game Tips and Help
Windows PC Help
Find Me on Google+
ADT on G+