download images from web api google

3 vues (au cours des 30 derniers jours)
michael scheinfeild
michael scheinfeild le 30 Août 2015
Commenté : Walter Roberson le 30 Août 2015
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

Réponse acceptée

Walter Roberson
Walter Roberson le 30 Août 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.

Plus de réponses (1)

michael scheinfeild
michael scheinfeild le 30 Août 2015
Modifié(e) : Walter Roberson le 30 Août 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 commentaire
Walter Roberson
Walter Roberson le 30 Août 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.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by