download images from web api google

6 views (last 30 days)
hi i want to search images of trees and download them as jpg i know there is google api how yo use it for images download

Accepted Answer

Walter Roberson
Walter Roberson on 30 Aug 2015
keyword = 'trees';
percent_escaped_keyword = regexprep(keyword, {' ', '&', '?', '<', '>'}, {'%20', '%26', '%3f', '%3c', '%3e'}); %it would be better to use some real routine for this
url = sprintf('https://www.google.com/search?q=site:images.google.com+%s&tbm=isch', precent_escaped_keyword);
Then you can urlread or urlwrite, and then you have the fun of trying to interpret the resulting HTML.
There is probably a real API, but it probably requires registration and an authentication token.

More Answers (1)

michael scheinfeild
michael scheinfeild on 30 Aug 2015
Edited: Walter Roberson on 30 Aug 2015
thank you but how to downloaded the images or read them ? i receive now : x=urelread(url) =
!doctype html><html dir="rtl" itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="iw"><head><meta content="text/html; cha .....................
  1 Comment
Walter Roberson
Walter Roberson on 30 Aug 2015
It looks to me as if the summary images presented show up in the HTML in the form
<img class="rg_i" src="
For example,
img class="rg_i" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRtZ2c-MyQtlEi5F_ydLMwQr0M9ER26_i7Y3Th1sS7nUIE2TrsIUUpLSJQ6" onload="google.aft&&google.aft(this)"><div class="rg_meta">{"tw":190, "th":266}</div></div></div><div class="rg_bb_label" style="font:18px/30px Arial,sans-serif" data-ved="0CB8QgzEoAGoVChMIoJnOieXRxwIVTyiICh3-pwd_"><div class="_Osc"><div class="_ucd">Clipart</div></div></div></div></a><a class="rg_fbl" data-query="tree drawings" data-title="Tree Drawings" href="/search?safe=off&biw=1652&bih=924&tbm=isch&q=tree+drawings&revid=1334743469&sa=X&ved=0CCEQ1QIoAWoVChMIoJnOieXRxwIVTyiICh3-pwd_" jsaction="fire.irc_fc;mouseover:str.hmov;mouseout:str.hmou"><div class="rg_bb rg_fb"><div class="rg_bb_i"><div class="rg_di rg_fr">
The href= would be the action from clicking on the image.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!