download images from web api google
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2015-8-30
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.
0 个评论
更多回答(1 个)
michael scheinfeild
2015-8-30
编辑:Walter Roberson
2015-8-30
1 个评论
Walter Roberson
2015-8-30
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!