search and download image

stefanoa

Active Member
Licensed User
Longtime User
search and download images

hi,
any ideas on how to search for images on google (with search words - for ex. "song name"), download it and view it as slideshow?
thanks
 
Last edited:

vb1992

Well-Known Member
Licensed User
Longtime User
Last edited:
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
thanks.. i'm studying the example of flicker...

1) to start, i've to compose a query string to pass to the google engine: example where "sunset" is the search key:
B4X:
 https://www.google.it/search?num=10&hl=it&site=imghp&tbm=isch&source=hp&biw=1280&bih=610&q=sunset&oq=sunset

2) i've to try to parse google result page, but it's very difficult than flicker.

for example, to extract the first image of result page, i think that i should extract then string "imgurl=http://www.hdwallpapersarena.com/wp-content/uploads/2012/08/red_sunset_beach.jpg"

B4X:
<div id="rg_hp" style="left:453px;top:223px;height:118px;width:170px" class="v">
<a id="rg_hpl" href="http://www.google.com/imgres?hl=en&amp;biw=1280&amp;bih=610&amp;tbm=isch&amp;tbnid=RXz4QApyJcCTjM:&amp;imgrefurl=http://www.hdwallpapersarena.com/romantic-sunset-beach-wallpapers.html&amp;imgurl=http://www.hdwallpapersarena.com/wp-content/uploads/2012/08/red_sunset_beach.jpg&amp;w=1024&amp;h=768&amp;ei=X8FAUMS-Gcf34QSGvYCQBw&amp;zoom=1&amp;iact=rc&amp;dur=148&amp;sig=100279770832253012655&amp;page=1&amp;tbnh=118&amp;tbnw=170&amp;start=0&amp;ndsp=18&amp;ved=1t:429,r:2,s:0,i:148&amp;tx=30&amp;ty=28" style="height: 118px; "></a>
<a id="rg_ahpl" href="#" style="bottom: 0px; height: 0px; "></a></div>

but where i try to load page in Textreader1, the buffer is full at 4096 char
B4X:
Dim TextReader1 As TextReader
TextReader1.Initialize(HttpUtils.GetInputStream(MainUrl)) '<<<  full at 4096

and then TextReader1 contain:
B4X:
<!doctype html><html itemscope="itemscope" itemtype="http://schema.org/WebPage"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta itemprop="image" content="/images/google_favicon_128.png"><title>sunset - Cerca con Google</title><style>#gb{font:13px/27px Arial,sans-serif;height:30px}#gbz,#gbg{position:absolute;white-space:nowrap;top:0;height:30px;z-index:1000}#gbz{left:0;padding-left:4px}#gbg{right:0;padding-right:5px}#gbs{background:transparent;position:absolute;top:-999px;visibility:hidden;z-index:998}.gbto #gbs{background:#fff}#gbx3,#gbx4{background-color:#2d2d2d;background-image:none;_background-image:none;background-position:0 -138px;background-repeat:repeat-x;border-bottom:1px solid #000;font-size:24px;height:29px;_height:30px;opacity:1;filter:alpha(opacity=100);position:absolute;top:0;width:100%;z-index:990}#gbx3{left:0}#gbx4{right:0}#gbb{position:relative}#gbbw{right:0;left:0;position:absolute;top:30px;width:100%}.gbtcb{position:absolute;visibility:hidden}#gbz .gbtcb{right:0}#gbg .gbtcb{left:0}.gbxx{display:none !important}.gbxo{opacity:0 !important;filter:alpha(opacity=0) !important}.gbm{position:absolute;z-index:999;top:-999px;visibility:hidden;text-align:left;border:1px solid #bebebe;background:#fff;-moz-box-shadow:-1px 1px 1px rgba(0,0,0,.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,.2);box-shadow:0 2px 4px rgba(0,0,0,.2)}.gbrtl .gbm{-moz-box-shadow:1px 1px 1px rgba(0,0,0,.2)}.gbto .gbm,.gbto #gbs{top:29px;visibility:visible}#gbz .gbm,#gbz #gbs{left:0}#gbg .gbm,#gbg #gbs{right:0}.gbxms{background-color:#ccc;display:block;position:absolute;z-index:1;top:-1px;left:-2px;right:-2px;bottom:-2px;opacity:.4;-moz-border-radius:3px;filter:progid:DXImageTransform.Microsoft.Blur(pixelradius=5);*opacity:1;*top:-2px;*left:-5px;*right:5px;*bottom:4px;-ms-filter:"progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";opacity:1\0/;top:-4px\0/;left:-6px\0/;right:5px\0/;bottom:4px\0/}.gbma{position:relative;top:-1px;border-style:solid dashed dashed;border-color:transparent;border-top-color:#c0c0c0;display:-moz-inline-box;display:inline-block;font-size:0;height:0;line-height:0;width:0;border-width:3px 3px 0;padding-top:1px;left:4px}#gbztms1,#gbi4m1,#gbi4s,#gbi4t{zoom:1}.gbtc,.gbmc,.gbmcc{display:block;list-style:none;margin:0;padding:0}.gbmc{background:#fff;padding:10px 0;position:relative;z-index:2;zoom:1}.gbt{position:relative;display:-moz-inline-box;display:inline-block;line-height:27px;padding:0;vertical-align:top}.gbt{*display:inline}.gbto{box-shadow:0 2px 4px rgba(0,0,0,.2);-moz-box-shadow:0 2px 4px rgba(0,0,0,.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,.2)}.gbzt,.gbgt{cursor:pointer;display:block;text-decoration:none !important}span#gbg6,span#gbg4{cursor:default}.gbts{border-left:1px solid transparent;border-right:1px solid transparent;display:block;*display:inline-block;padding:0 5px;position:relative;z-index:1000}.gbts{*display:inline}.gbto .gbts{background:#fff;border-color:#bebebe;color:#36c;padding-bottom:1px;padding-top:2px}.gbz0l .gbts{color:#fff;font-weight:bold}.gbtsa{padding-right:9px}#gbz .gbzt,#gbz .gbgt,#gbg .gbgt{color:#ccc!important}.gbtb2{display:block;border-top:2px solid transparent}.gbto .gbzt .gbtb2,.gbto .gbgt .gbtb2{border-top-width:0}.gbtb .gbts{background:url(//ssl.gstatic.com/gb/images/b_8d5afc09.png);_background:url(//ssl.gstatic.com/gb/images/b8_3615d64d.png);background-position:-27px -22px;border:0;font-size:0;padding:29px 0 0;*padding:27px 0 0;width:1px}.gbzt-hvr,.gbzt:focus,.gbgt-hvr,.gbgt:focus{background-color:#4c4c4c;background-image:none;_background-image:none;background-position:0 -102px;background-repeat:repeat-x;outline:none;text-decoration:none !important}.gbpdjs .gbto .gbm{min-width:99%}.gbz0l .gbtb2{border-top-color:#dd4b39!important}#gbi4s,#gbi4s1{font-weight:bold}#gbg6.gbgt-hvr,#gbg6.gbgt:focus{background-color:transparent;background-image:none}.gbg4a{font-size:0;line-height:0}.gbg4a .gbts{padding:27px 5px 0;*padding:25px 5px 0}.gbto .gbg4a .gbts{padding:29px 5px 1px;*padding:27px 5px 1px}#gbi4i,#gbi4id{left:5px;border:0;h
and so i have not the images link..

how can I overcome this limit? and it's correct this method?
thanks
 
Last edited:
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
i've not an error..
but the field TextReader1 contains only 4096 char..

B4X:
Dim TextReader1 As TextReader
TextReader1.Initialize(HttpUtils.GetInputStream(MainUrl))
............
Dim line As String
line = TextReader1.ReadLine
Do While line <> Null
   Log("Line: " & line)   '<<<  ONLY 1 line with 4096 char...
   line = TextReader1.ReadLine
Loop
TextReader1.Close
 
Upvote 0
Top