menu * { Image Search:dialog -m ig ig } dialog ig { size -1 -1 200 100 title "Image Google by Patje`" option dbu box "Image to look up", 1, 5 3 190 25 edit "", 2, 10 12 145 10 button "Search!", 3, 160 12 30 10 box "Current Download:", 4, 5 30 190 25 text "Status:", 5, 12 38 180 10 } on *:DIALOG:ig:sclick:*:{ if (($did == 3) && ($iif($did(2),$v1,$?="You have to supply data to look up!"))) { inc %sc sockopen $+(ig.,%sc) images.google.com 80 sockmark $+(ig.,%sc) $hr($v1) } } on *:SOCKOPEN:ig.*:{ .remove igt | unset %y did -a ig 5 Status: Searching for image sockwrite -nt $sockname GET /images?um=1&tab=wi&ie=UTF-8&oe=UTF-8&q= $+ $sock($sockname).mark HTTP/1.0 sockwrite -nt $sockname Host: images.google.com sockwrite -nt $sockname $crlf } on *:SOCKREAD:ig.*:{ if ($sockerr) halt while ($sock($sockname).rq) { sockread &ig | bwrite igt -1 -1 &ig } bread igt 0 $file(igt).size &ig if ((!%y) && ($bfind(&ig,1,))) { if ($bfind(&ig,1,58 34 44 34 104 116 116 112 58 47 47)) { set %y $bvar(&ig,$calc($v1 + 4),$calc($bfind(&ig,$calc($v1 + 6),34) - $calc($v1 + 4))).text did -a ig 5 Status: Downloading picture sockopen $+(id.,%sc) $gurl(%y).host 80 sockmark $+(id.,%sc) $gurl(%y).host $gurl(%y).get .timer 1 2 unset %y } else did -a ig 5 Status: There are no results found for $sock($sockname).mark } .timer 1 2 .remove igt } on *:SOCKOPEN:id.*:{ sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0 sockwrite -nt $sockname Host: $gettok($sock($sockname).mark,1,32) sockwrite -nt $sockname $crlf } on *:SOCKREAD:id.*:{ if ($sockerr) halt did -a ig 5 Status: Sockread reached while ($sock($sockname).rq) { var %id | sockread %id if (Content-Length: * iswm %id) echo -a found! $gettok(%id,2,32) if (!%id) break } sockread &id while ($sockbr) { echo -a $sock($sockname).mark bwrite $nopath($gettok($sock($sockname).mark,2,32)) -1 -1 &id sockread &id } } alias gurl { if ($prop == host) return $gettok($remove($1-,http://,www.),1,47) if ($prop == get) return / $+ $gettok($remove($1-,http://,www.),2-,47) } alias hr return $replace($1-,$chr(32),+)