Format for a url that goes to Google image search?

JavascriptHtmlHyperlinkGoogle Api

Javascript Problem Overview


I have a web page which has links at the bottom like this:

- <a href='http://www.google.com/q?rome+photos'>photos of rome</a>
- <a href='http://www.google.com/q?paris+photos'>photos of paris</a>
- <a href='http://www.google.com/q?london+photos'>photos of london</a>

The idea is that if somebody clicks we go to Google search image page and we search for those images of those cities.

The questions are:

  1. what's the right URL for starting an image search in Google
  2. is there a place in Google documentation where I can find this ? (I searched and could not find it)
  3. does Google restrict this type of usage for some reasons?

Edit: The 3rd point is very important to me: it's okay to work out the url from blogs and others but the question remains: is google okay with this ? will it ever discourage this approach ? if so then all my urls would become suddenly worth nothing

Javascript Solutions


Solution 1 - Javascript

  1. url: https://www.google.com/search?tbm=isch&q=findSomeImage,
  2. Nothing official that I'm aware of, but this blog has some documentation.
  3. Nope, no limit you should worry about if you're manually clicking the urls. (I'm sure google has some kind of flood protection against bots, though)

So, the only change you have to make, is to add the tbm=isch option to your urls.

Solution 2 - Javascript

http://www.google.com/search?q=<SEARCH TERM>&tbm=isch

The tbm=isch is the internal google search parameter that determines what kind of search to perform. There doesn't seem to be any official documentation on it, but this page has a decent write up:

Google Search Request Params

EDIT:

It looks like if you don't include the "/search" part of the string, it fills the google searchbox, but doesn't actually execute the search.

Solution 3 - Javascript

Use the "images" keyword instead of "search" (this should also work for "videos", "maps", etc.)

http://www.google.com/images?q=your+search+terms

https://productforums.google.com/d/msg/websearch/No-YWMdgFp8/l_SNghlwCV0J

Update

Following Chris F Carroll's comment below, I had a look with Fiddler. The /images request results in a 301 (moved permanently) response with the redirect URL in the format www.google.com/search?q=search+terms&tbm=isch as described by other answers here.

Contrary to what I said above (taken from the linked article), the /video request doesn't work. /maps does work, and doesn't result in a redirect.

Solution 4 - Javascript

Please use below URL for google image search

http://images.google.com/images?um=1&hl=en&safe=active&nfpr=1&q=your_search_query

Replace your_search_query with your own search term. Please note this url will behave differently according to the user agent. Google can identify whether this request comes from a browser or a bot

Also note you can add another query string to navigate through this image search

http://images.google.com/images?um=1&hl=en&safe=active&nfpr=1&q=your_search_query&start=30

This will make the search start from 3rd page. I hope this helps somebody.

Solution 5 - Javascript

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZo72View Question on Stackoverflow
Solution 1 - JavascriptCerbrusView Answer on Stackoverflow
Solution 2 - JavascriptStephen WrightView Answer on Stackoverflow
Solution 3 - JavascriptIan HorwillView Answer on Stackoverflow
Solution 4 - JavascriptcherankrishView Answer on Stackoverflow
Solution 5 - Javascriptmiso.soflwView Answer on Stackoverflow