Jump to content

Recommended Posts

hallo,

i am trying to write a script which does the following thing:

it should search for a special search tag in google picture (the search tags are saved in a database)

than it should get the link of the first picture, google picture finds with this searchtag.

than it should take the picture and resize it so a spezial size

after this it should save the picture in a special directory and rename it into searchtag.jpg

 

so my question is, is it possible to make such a script or is it completely unpossible ?

i spent some time at the code of google pictures and this is what I found out:

if i want to get the link of the first picture, i have to select the second link, which starts with "http://" and ends with "jpg, png, tiff or whatever".

 

so my question is now, how can i make the following things work:

 

- how can i get the code of the google picture site with php ?

- is it possible to resize a picture with php ?

- is it aso possible to transform the fileformat ? (for example every picture into .jpg or .png ?)

 

and at the end i want to tell you, for what i want to use this:

i am trying to write a skript for mediamanagement of local media

(everything like: dokuments, musik, films, .... so all kind of media)

and it would look nice, if there would be some thumbnails, when you search throw your media ...

(and sry if my english is not the best, but my motherlanguage is german)

Link to comment
https://forums.phpfreaks.com/topic/129948-google-picture-first-picture-php/
Share on other sites

initially it is, i started testing this myself and managed to send a custom image query from my script and store the results in a variable.

 

the problem is that i can count the number of words but can't find ant strings:

i'm not exactly sure where its cause but there's a discrepancy somewhere...

 

- my request headers accept gzip/deflate encoding, and Latin1 and UTF8 and the response is text/html and UTF8... but chunked

 

and i pasted the result as-is below (im not sure of its the chunking or maybe the selective gzipping of only the javascript and/or css that they might employ, but its not very legible.

 

ANYHOW:the image results are dynamically inserted into a table in the document using javascript, numbered (0-indexed) ID for the <td> and with the following prefix: "tDataImage"

 

but notice how when i search the output for "tDataImage" (and i SAW tDataImage0, tDataImage1, ...tDataImage24 on the page) it found nothing.

 

so this is where im at, maybe somene else will pick up from here if not ill do it later.... heres the results:

 

and comments at the end:

 

<?php
// stripped a bunch of useless GET stuff that is sent: browser version, referral, etc
// it worked for a bit with or without the info so i imagine they have some IP/cookie anti-spammer // check cause i cant get it to work from within PHP anymore

// stripped query string
$taz = 'http://images.google.com/images?um=1&hl=en&q=taz&btnG=Search+Images';

// original string 
// $taz = 'http://images.google.com.br/images?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=wi'

if($fh = fopen($taz, 'r')){
$content = '';
while($line = fread($fh, 1024)){
	$content .= $line;
}
fclose($fh);
echo 'response length = '.str_word_count($content).'<br>';
die (var_dump(strpos('tDataImage',$content)));<br />
}else{
die('google sucks');
}
?>

 

 

anyway i cant work on this anymore but its a start...

 

here's the REQUEST PARAMS:

 

client firefox-a

ie UTF-8

oe utf-8

q taz

rls org.mozilla:en-US:official

sa N

tab wi

um 1

 

REQUEST HEADERS

 

Host images.google.com.br

User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (.NET CLR 3.5.30729)

Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language en-us,en;q=0.8,pt-br;q=0.6,pt;q=0.4,es;q=0.2

Accept-Encoding gzip,deflate

Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive 300

Connection keep-alive

Referer http://www.google.com.br/search?q=taz&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

 

RESPONSE HEADERS

 

Response Headers

Via xxxxxxxxxxxxxxsorry!

Connection Keep-Alive

Proxy-Connection Keep-Alive

Transfer-Encoding chunked

Expires -1

Date Fri, 24 Oct 2008 15:43:28 GMT

Content-Type text/html; charset=UTF-8

Server gws

Cache-Control private, max-age=0

Set-Cookie xxxxxxxxxxx (sorry); path=/search

 

and this is the RESPONSE DUMP  (ADMINS IF THERES ANYTHING WRONG/ILLEGAL/ETC/COPYRIGHT INFRINGEMENT/WHATEVER WITH THIS PLEASE DELETE IM JUST TRYING TO HELP NO HARM INTENDED!!)

<html><head><meta http-equiv=content-type content="text/html; charset=UTF-8"><title>taz - Google Image Search</title><style>div,td,.n a,.n a:visited{color:#000}.ts td,.tc{padding:0}.ts,.tb{border-collapse:collapse}.ti{display:inline}.ti{display:inline-table}.hd{position:absolute;width:1px;height:1px;top:-1000em;overflow:hidden}.f{color:#666}.flc,a.fl{color:#77c}a,.w,.q:visited,.q:active,.q,.b a,.b a:visited{color:#00c}a:visited{color:#551a8b}a:active{color:red}.t{background:#d5ddf3;color:#000;padding:5px 1px 4px}.bb{border-bottom:1px solid #36c}.bt{border-top:1px solid #36c}.j{width:34em}.h{color:#36c}.i{color:#a90a08}.a{color:green}.z{display:none}div.n{margin-top:1ex}.n a,.n .i{font-size:10pt}.n .i,.b a{font-weight:bold}.b a{font-size:12pt}.std{font-size:82%}.xsm{font-size:67%}#np,#nn,.nr,#logo span,.ch{cursor:pointer;cursor:hand}.ta{padding:3px 3px 3px 5px}#tpa2,#tpa3{padding-top:9px}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}.sl,.r{display:inline;font-weight:normal;margin:0}.sl{font-size:84%}.r{font-size:100%}.csb,.n div,#logo span{background:url(/images/nav_logo3.png) no-repeat;height:26px;overflow:hidden}.n .nr{background-position:-60px 0;width:16px}#np{width:44px}#nf{background-position:-26px 0;width:18px}#nc{background-position:-44px 0;width:16px}#nn{margin-right:34px;width:66px}#nl{width:46px}#nn,#nl{background-position:-76px 0}#logo{display:block;height:52px;margin:13px 0 7px;overflow:hidden;position:relative;width:150px}#logo span{background-position:0 -26px;height:100%;left:0;position:absolute;top:0;width:100%}.ss{background:url(/images/nav_logo3.png) no-repeat;background-position:0 -87px;display:block;left:0;overflow:hidden;position:absolute;top:0}.cps{overflow:hidden;height:18px;width:114px}em{font-weight:bold;font-style:normal}body,td,div,.p,a{font-family:arial,sans-serif}#sd{font-size:84%;font-weight:bold}#ap{font-size:64%}</style>
<script>window.google={kEI:"IO0BSeflM4u60gXly4i0Dg",kEXPI:"18878",kHL:"en"};
function g(c){var d="undefined",a="1";if(c&&c.getElementById)if(typeof XMLHttpRequest!=d)a="2";else if(typeof ActiveXObject!=d){var b,e,f="MSXML2.XMLHTTP",h=[f+".6.0",f+".3.0",f,"Microsoft.XMLHTTP"];for(b=0,e;e=h[b++];)try{new ActiveXObject(e);a="2"}catch(i){}}return a};window.maybeRedirectForGBV=function(c,d,a){var b=g(c);if(b!=a)d.href="http://images.google.com.br/images?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=wi&ei=IO0BSeflM4u60gXly4i0Dg&gbv="+b};
maybeRedirectForGBV(document,location,"2");window._isr_load=function(a){var b=a.options[a.selectedIndex].value;if(b)location.href=b;return false};
window.clk=function(b,c,d,e,f,g){if(document.images){var a=encodeURIComponent||escape;(new Image).src="/url?sa=T\x26source\x3dimg"+(c?"&oi="+a(c):"")+(d?"&cad="+a(d):"")+"&ct="+a(e)+"&cd="+a(f)+(b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"")+"&ei=IO0BSeflM4u60gXly4i0Dg"+g}return true};
window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#".parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff topmargin=3 marginheight=3 ><noscript><meta HTTP-EQUIV="refresh" content="0;url=http://images.google.com.br/images?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=wi&gbv=1&ei=IO0BSeflM4u60gXly4i0Dg"><style><!--
table,div,span,font,p{display:none}
--></style>
<div style="display:block">Please click <a href="http://images.google.com.br/images?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=wi&gbv=1">here</a> if you are not redirected within a few seconds.</div></noscript><div id=gbar><nobr><a href="http://www.google.com.br/search?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=iw" onclick=gbar.qs(this) class=gb1>Web</a> <b class=gb1>Images</b> <a href="http://maps.google.com.br/maps?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=il" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com.br/news?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=in" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.orkut.com/UniversalSearch.aspx?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=i0" onclick=gbar.qs(this) class=gb1>Orkut</a> <a href="http://mail.google.com/mail/?ie=UTF-8&sa=N&tab=im" class=gb1>Gmail</a> <a href="http://www.google.com.br/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>&#9660;</small></a><div id=gbi> <a href="http://groups.google.com.br/groups?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=ig" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com.br/books?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=ip" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com.br/scholar?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=is" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://blogsearch.google.com.br/blogsearch?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=ib" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://br.youtube.com/results?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=i1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?ie=UTF-8&sa=N&tab=ic" class=gb2>Calendar</a> <a href="http://picasaweb.google.com.br/lh/searchbrowse?q=taz&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=iq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?ie=UTF-8&sa=N&tab=io" class=gb2>Documents</a> <a href="http://www.google.com.br/reader/view/?ie=UTF-8&sa=N&tab=iy" class=gb2>Reader</a> <a href="http://sites.google.com/?ie=UTF-8&sa=N&tab=i3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com.br/intl/en/options/" class=gb2>even more »</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="https://www.google.com/accounts/Login?continue=http://images.google.com.br/images%3Fq%3Dtaz%26ie%3DUTF-8%26oe%3Dutf-8%26rls%3Dorg.mozilla:en-US:official%26client%3Dfirefox-a%26um%3D1%26sa%3DN%26tab%3Dwi&hl=en">Sign in</a></nobr></div><table id=sft class=tb style=clear:left width=100%><tr><form name=gs method=GET action="/images"><td class=tc valign=top><a id=logo href="http://www.google.com.br/webhp?hl=en" title="Go to Google Home">Google<span></span></a></td><td style="padding:0 0 7px;padding-left:8px" valign=top width=100%><table class=tb style="margin-top:25px"><tr><td class=tc nowrap><input type=hidden name=um value=1><input type=hidden name=hl value="en"><input type=hidden name=client value="firefox-a"><input type=hidden name=rls value="org.mozilla:en-US:official"><input type=text name=q size=41 maxlength=2048 value="taz" title="Search Images"> <input type=submit name="btnG" value="Search Images"> <input type=submit name="btnmeta=search=search" value="Search the Web"></td><td class=tc nowrap width=100%><span id=ap>  <a href="/advanced_image_search?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official">Advanced Image Search</a><br>  <a href="/preferences?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official">Preferences</a></span></td></tr><tr><td class=tc colspan=2><font size=-1> <a href="/preferences#">Moderate SafeSearch is on</a></font></td></tr></table></td></tr></form></table><table border=0 cellpadding=0 cellspacing=0 width=100% class="t bt"><tr><td nowrap><span id=sd> Images </span><font size=-1>   Showing:  </font></td><td width=98%><form style="margin:0"><select name="imagesize" style="margin:2px 0" onchange="_isr_load(this)"><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgsz=" selected>All image sizes</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgsz=huge" >Extra Large images</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgsz=xxlarge" >Large images</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgsz=small|medium|large|xlarge" >Medium images</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgsz=icon" >Small images</option></select>  <select name="imagetype" style="margin:2px 0" onchange="_isr_load(this)"><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgtype=" selected>Any content</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgtype=news&as_st=y" >News content</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgtype=face&as_st=y" >Faces</option><option value="/images?q=taz&um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&sa=N&imgtype=photo&as_st=y" >Photo content</option></select></form></td><td align=right nowrap id=resultStats><font size=-1>Results <b><span id=lowerLimit>1</span></b> - <b><span id=upperLimit>21</span></b> of about <b><span id=maxLimit>1,650,000</span></b> for <b>taz</b>.  (<b>0.31</b> seconds) </font></table><div><div style="font-size:100%;width:100%;margin-top:10px">Related searches:<span style="padding:0 0 0 8px"><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=baby+taz&revid=1312963127&sa=X&oi=revisions_inline&resnum=0&ct=broad-revision&cd=1"><b>baby</b> taz</a>    <a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=tweety&revid=1312963127&sa=X&oi=revisions_inline&resnum=0&ct=broad-revision&cd=2"><b>tweety</b></a>    </span></div><br><div id=ImgContent></div><script><!--
window.dyn = {};(function() {function h(a,c,d){var b="on"+c;if(a.addEventListener)a.addEventListener(c,d,false);else if(a.attachEvent)a.attachEvent(b,d);else{var f=a[b];a[b]=function(){var g=f.apply(this,arguments),i=d.apply(this,arguments);return g==undefined?i:(i==undefined?g:i&&g)}}};var j=window.dyn,k="tDataImage",m=[],o=0,p="",q="",r="",s=0;j.shouldShowAllImages=false;j.showBigFont=false;var t=3;window.onresize=u;function v(a,c,d,b){p=a;q=c;r=d;s=parseInt(b,10);h(window,"load",w);var f=x();y(f)}function w(){var a=z("navbar");if(a&&a.getElementsByTagName){var c=a.getElementsByTagName("a");for(var d=0;d<c.length;d++)c[d].onclick=function(){return A(this)}}}function x(){if(document&&document.body&&document.body.clientWidth)return document.body.clientWidth;else return window.innerWidth}
function B(){if(document&&document.body&&document.body.clientHeight)return document.body.clientHeight;else return window.innerHeight}function C(a){return Math.ceil(17/a)*a}function y(a){var c=0;t=D(a);var d=j.shouldShowAllImages?21:C(t),b=Math.ceil(d/t),f="<table width=100% cellspacing=0 cellpadding=0 border=0>";for(var g=0;g<b;g++){var i="<tr>",l="<tr>";for(var n=0;n<t;n++){i+="<td id="+k+c+" align=center nowrap valign=bottom width="+100/t+"%></td>";l+="<td id=tDataText"+c+" align=center valign=top width="+
100/t+"%></td>";c++}i+="</tr>";l+="</tr>";f+=i+l}f+="</table>";z("ImgContent").innerHTML=f}function E(){var a=C(t);F(a);G(a)}function F(a){var c=s,d=parseInt(z("upperLimit").innerHTML,10);if(c<0)return;if(!isNaN(d)&&c>=d)return;var b=j.shouldShowAllImages?m.length:a;if(m.length<b)b=m.length;b=c+b;z("lowerLimit").innerHTML=c+1;z("upperLimit").innerHTML=b}function D(a){var c=0;if(!a)c=4;else if(a<=H(690))c=3;else if(a<H(800))c=4;else c=Math.max(Math.floor(a/H(200)),3);return c>7?7:c}function H(a){var c;
if(c=document.createElement("div")){c.style.width="10em";document.body.appendChild(c);var d=c.offsetWidth/10;document.body.removeChild(c);return d?Math.ceil(12.5*d*a/200):a}return a}function G(a){if(Math.random()<=0.01)(new Image).src="/gen_204?bw="+x()+"&bh="+B()+"&ncols="+t+"&nimg="+a+"&atyp=i"}function u(){var a=x();if(D(a)!=t){y(a);var c=C(t);F(c);if(j.shouldShowAllImages)c=m.length;for(var d=0;d<c;d++)I(d)}}function J(a,c,d,b,f,g,i,l,n,L,M,N,O,P,Q,R,S,T){var e=new Image;e.k=a;e.r=c;e.e=d;e.c=
b;e.d=f;e.b=g;e.i=i;e.h=l;e.l=n;e.q=L;e.j=M;e.n=N;e.g=O;e.f=P;e.m=Q;e.p=R;e.a=S;e.o=T;m[o]=e;var U=C(t);if(o<U||j.shouldShowAllImages)I(o);o++}function I(a){var c="",d="";if(a>=m.length)return;var b=m[a];z(k+a).style.paddingTop=a<t?"0px":"20px";var f="";if(b.a&&b.a.length>0)f="&altq="+b.a.join();var g;if(b.o=="1")g="/imgres?imgurl="+(b.c.indexOf("://")<0?"http://":"")+b.c+"&imgrefurl="+b.k+"&tbnid="+b.e+f+"&tbnh="+b.b+"&tbnw="+b.d+r+"&prev="+q;else g=b.k;c+="<a href="+g+b.r+"><img style='border:1px solid;' src="+
b.m+"?q=tbn:"+b.e+(b.p=="1"?b.c:"");if(b.d!=""&&b.b!="")c+=" width="+b.d+" height="+b.b;c+="></a>";z(k+a).innerHTML=c;d+="<font face=arial,sans-serif size=-1>";if(j.showBigFont)d+="<font size=3>"+b.i+"</font>";else d+=b.i;if(b.l!=""){d+="<span class=m>";if(b.h!="")d+=" <font dir=ltr>- "+b.h+"</font>"+=" <font dir=ltr>- "+b.l+"</font></span>"}d+="<br>"+b.q+(b.j?" - "+b.j:"")+"<br><font color="+p+">"+b.n+"</font>";if(b.g!=""&&b.f!="")d+="<br>[ <a class=fl href='"+b.g+"'>"+b.f+"</a> ]";
d+="</font>";z("tDataText"+a).innerHTML=d}function A(a){document.location.href=K(document.location.href,a.href);return false}function K(a,c){var d=a.match(/[?&]ndsp=(\d+)/),b=d&&eval(d[1])>0?eval(d[1]):21,f=c.match(/[?&]start=(\d+)/),g=f&&eval(f[1])>0?eval(f[1]):0,i=Math.round(g/b),l=C(t),n=i*l;c=V(c,"start",n);c=V(c,"ndsp",l);return c}function V(a,c,d){return[a.replace(new RegExp("([?&])"+c+"=([^&]*)","i"),"$1"),"&",c,"=",d].join("")}function z(a){return document.getElementById(a)}j.initialize=v;
j.updateStatus=E;j.Img=J;
}) ();dyn.initialize("#008000", "/images%3Fq%3Dtaz%26um%3D1%26hl%3Den%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26sa%3DN","", "0");dyn.Img("http://people.bu.edu/wwildman/ben/tassie/warnerbros.htm&h=655&w=523&sz=45&hl=en&start=1&um=1&usg=__1_uNELrdFenqsvwC4OwKc-P_QSo=","","LXcI30g3DlRiyM:","http://people.bu.edu/wwildman/ben/tassie/taz.jpg","110","138","Tassie at Warner Bros. (\x3cb\x3eTAZ\x3c/b\x3e)","","","523 x 655 - 45k","jpg","people.bu.edu","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://i-love-cartoons.com/snags/clipart/Looney-Tunes/Taz.php&h=479&w=300&sz=105&hl=en&start=2&um=1&usg=__aEandzRZZ_PaOQ8SurCR0VTsvq4=","","SXhT9LLVXDT1bM:","http://i-love-cartoons.com/snags/clipart/Looney-Toons/Taz/Taz-Tornado.jpg","81","129","\x3cb\x3eTaz\x3c/b\x3e","","","300 x 479 - 105k","jpg","i-love-cartoons.com","/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=+site:i-love-cartoons.com+taz","More from i-love-cartoons.com","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://bonodavi.wordpress.com/2008/08/03/cartoons/&h=907&w=700&sz=182&hl=en&start=3&um=1&usg=__rRfrlhrz-h5IWXBbCGtKIgK4la4=","","A61ENG6oOcwR_M:","http://bonodavi.files.wordpress.com/2008/08/taz.jpg","113","147","\x3cb\x3eTaz\x3c/b\x3e. Veja outros cartoons aqui:","","","700 x 907 - 182k","jpg","bonodavi.wordpress.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.blogger.com/profile/04852554295742603628&h=977&w=1200&sz=83&hl=en&start=4&um=1&usg=__o_tiQL2yHhCtyOgTnVJNmxedfdI=","","fG_4LIhKYmVvbM:","http://www.gwrra-mi.org/Images/clipart/TAZ.jpg","150","122","Blogger: User Profile: \x3cb\x3eTaz\x3c/b\x3e","","","1200 x 977 - 83k","jpg","www.blogger.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.imyspacegraphics.com/taz-myspace-graphics.php&h=300&w=400&sz=66&hl=en&start=5&um=1&usg=__z5eJ2UwW8ERObu6Tt0j5ntvFHAA=","","qL5GnZt2dQQBUM:","http://www.imyspacegraphics.com/images/taz/taz1.jpg","124","93","\x3cb\x3eTaz\x3c/b\x3e MySpace Graphics","","","400 x 300 - 66k","jpg","www.imyspacegraphics.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://i-love-cartoons.com/snags/clipart/Looney-Tunes/Taz.php&h=307&w=279&sz=78&hl=en&start=6&um=1&usg=__EvkZbvN5nuDbMXPMtmCGJaHnQPY=","","2IbfNP3WzMU3oM:","http://i-love-cartoons.com/snags/clipart/Looney-Toons/Taz/Secret-agent-taz.jpg","106","117","\x3cb\x3eTaz\x3c/b\x3e","","","279 x 307 - 78k","jpg","i-love-cartoons.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.generalforum.com/movies-tv/cartoon-character-you-most-like-46104.html&h=273&w=324&sz=28&hl=en&start=7&um=1&usg=__O9QuCw1lumQ6dwHqQivJhmvygXQ=","","uUAXiz9QvbMtKM:","http://hometown-art.aol.com/htp/clipart/entertainment_and_arts/Looney32Tunes/source/taz2.gif","118","99","That\x26#39;s right, it\x26#39;s \x3cb\x3eTaz\x3c/b\x3e from Looney \x3cb\x3e...\x3c/b\x3e","","","324 x 273 - 28k","gif","www.generalforum.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.dan-dare.org/FreeFun/Games/CartoonsMoviesTV/Taz2.htm&h=360&w=440&sz=33&hl=en&start=8&um=1&usg=__c0riorLQ5ZDfRfAzr-OfZdyTacc=","","Ma929rpM2q4muM:","http://www.dan-dare.org/FreeFun/Images/CartoonsMoviesTV/Taz.jpg","127","104","\x3cb\x3eTaz\x3c/b\x3e the Tazmanian Devil","","","440 x 360 - 33k","jpg","www.dan-dare.org","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://my.barackobama.com/page/community/blog/taz/2008/07&h=359&w=413&sz=49&hl=en&start=9&um=1&usg=__4giY1LAIhK5X-yf6CygubB8iCw0=","","p8qtlm5R08W2yM:","http://www.mbpadvertising.com/images/taz.jpg","125","109","By \x3cb\x3eTAZ\x3c/b\x3e: Obama/Biden 08 - Jul 25th, \x3cb\x3e...\x3c/b\x3e","","","413 x 359 - 49k","jpg","my.barackobama.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.geocities.com/CollegePark/Lounge/6707/emma.html&h=303&w=300&sz=20&hl=en&start=10&um=1&usg=__kpazRPu8pwR0roeZm2a_Kx-BVKE=","","iqPPMt6ke_DhxM:","http://www.geocities.com/CollegePark/Lounge/6707/taz.jpg","115","116","\x3cb\x3etaz\x3c/b\x3e.jpg (20264 bytes)","","","300 x 303 - 20k","jpg","www.geocities.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.alexross.com/Tazbride2.html&h=476&w=648&sz=71&hl=en&start=11&um=1&usg=__gmo1h55CCoMsPkXjBBG0MwEUjXU=","","LqbZEvOSBBcBMM:","http://www.alexross.com/Taz%2520Wedding%2520II.jpg","137","101","\x3cb\x3eTaz\x3c/b\x3e Wedding","","","648 x 476 - 71k","jpg","www.alexross.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.toonstown.com/warnerbrosstatues2.htm&h=377&w=400&sz=37&hl=en&start=12&um=1&usg=__2U9hXgU9P22vV2osllasDzsZV0E=","","oB0sp0Dlw8wOkM:","http://www.toonstown.com/Taz%25205-12-03%2520new%25207-03.gif","124","117","\x3cb\x3eTaz\x3c/b\x3e. Approx. 7.3 in. high","","","400 x 377 - 37k","gif","www.toonstown.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.stowe.k12.vt.us/SMS/teachers/sbuzzell/index.htm&h=977&w=1200&sz=175&hl=en&start=13&um=1&usg=__oQBtnzY-k50zyod8Go93uzXtYN8=","","q2LEbXQkbxh1MM:","http://www.stowe.k12.vt.us/SMS/teachers/sbuzzell/images/Taz.jpg","150","122","Click on \x3cb\x3eTaz\x3c/b\x3e","","","1200 x 977 - 175k","jpg","www.stowe.k12.vt.us","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.80stees.com/products/adult-taz-costume.asp&h=500&w=420&sz=27&hl=en&start=14&um=1&usg=__oSje5xxWPFeIdFohKLGJOAUr3QA=","","wBvyHELTSTA45M:","http://www.80stees.com/images/products/Looney_Tunes_Taz-Costume.jpg","109","130","Looney Tunes t-shirts \x26gt; \x3cb\x3eTaz\x3c/b\x3e Costume","","","420 x 500 - 27k","jpg","www.80stees.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.cartoonspot.net/looney-tunes/taz.php&h=297&w=445&sz=24&hl=en&start=15&um=1&usg=__L1Wn6zeRzUr8zrtCMq5qMvump8w=","","2xduR1AiwPAkgM:","http://www.cartoonspot.net/looney-tunes/images-looney-tunes/taz-A.jpg","127","85","\x3cb\x3eTaz\x3c/b\x3e : Looney Tunes spot","","","445 x 297 - 24k","jpg","www.cartoonspot.net","/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=+site:www.cartoonspot.net+taz","More from www.cartoonspot.net","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.showerail.com/disney.htm&h=546&w=334&sz=34&hl=en&start=16&um=1&usg=__ugKzsH5J76658AusDzrrfbq3SyA=","","wjQFbs8286D6zM:","http://www.showerail.com/images/Taz.jpg","81","133","\x3cb\x3eTaz\x3c/b\x3e Shower Curtain","","","334 x 546 - 34k","jpg","www.showerail.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://profile.myspace.com/index.cfm%3Ffuseaction%3Duser.viewprofile%26friendid%3D95976854&h=333&w=300&sz=73&hl=en&start=17&um=1&usg=__dt84KFsdhQsQShmcAQVNmimQjTU=","","BZHP689SjkqKYM:","http://www.2hotrecords.com/myspace/profile/taz/2hotLogo-taz.jpg","107","119","\x3cb\x3e...\x3c/b\x3e gold rush \x3cb\x3etaz\x3c/b\x3e $krilla skrilla 2","","","300 x 333 - 73k","jpg","profile.myspace.com","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.meupapeldeparedegratis.com.br/cartoons/pages/taz.asp&h=768&w=1024&sz=533&hl=en&start=18&um=1&usg=__WcHad6r7Jpb8MFpixwz8XsiH-xw=","","BIFUABAjwDWBlM:","http://www.myfreewallpapers.net/cartoons/wallpapers/taz.jpg","150","113","\x3cb\x3e...\x3c/b\x3e Gratuito de Desenhos : \x3cb\x3eTaz\x3c/b\x3e","","","1024 x 768 - 533k","jpg","www.meupapeldeparedegratis.com.br","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("https://www.movieeye.com/store/product_details.jsp%3Fid%3D2522%26sbct%3DAnimation%26ct%3DPosters&h=521&w=350&sz=27&hl=en&start=19&um=1&usg=__O2i8Hs7XqDewQnu0nHjiCQyU1R4=","","tjUY6B5mFMKleM:","http://images.movieeye.com/store/images/space-jam-taz-movie-poster.jpg","88","131","Space Jam - \x3cb\x3eTaz\x3c/b\x3e - Original","","","350 x 521 - 27k","jpg","","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://www.mobilecastle.biz/mobiles/themes/2837-sketch-taz-theme.html&h=472&w=646&sz=71&hl=en&start=20&um=1&usg=__l9OSK8ehF1Qq9B5p7FYUY_7XceQ=","","6li8N5ojomJvLM:","http://img400.imageshack.us/img400/8149/taz8yi.jpg","137","100","Sketch \x3cb\x3eTaz\x3c/b\x3e Theme","","","646 x 472 - 71k","jpg","www.mobilecastle.biz","","","http://tbn0.google.com/images","1",[],"1");dyn.Img("http://pt.fontriver.com/font/taz_the_devil/&h=577&w=532&sz=16&hl=en&start=21&um=1&usg=__s0PGCUfFWVTkQZ1BhvWgWDnbDcg=","","RxvXb1Mig51ByM:","http://www.fontriver.com/i/maps/taz_the_devil_map.png","124","134","\x3cb\x3eTaz\x3c/b\x3e the Devil Caracteres Válidos","","","532 x 577 - 16k","png","pt.fontriver.com","","","http://tbn0.google.com/images","1",[],"1");dyn.updateStatus();//-->
</script><br clear="all"/><div id=navbar class=n><table border=0 cellpadding=0 width="1%" cellspacing=0 align=center><tr align=center style=text-align:center valign=top><td nowrap align=right class=b><div id=nf></div><td nowrap><div id=nc></div><span class=i>1</span><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=21&sa=N"><div class=nr></div><span>2</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=42&sa=N"><div class=nr></div><span>3</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=63&sa=N"><div class=nr></div><span>4</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=84&sa=N"><div class=nr></div><span>5</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=105&sa=N"><div class=nr></div><span>6</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=126&sa=N"><div class=nr></div><span>7</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=147&sa=N"><div class=nr></div><span>8</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=168&sa=N"><div class=nr></div><span>9</span></a><td nowrap><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=189&sa=N"><div class=nr></div><span>10</span></a><td nowrap class=b><a href="/images?um=1&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&q=taz&start=21&sa=N"><div id=nn></div><span>Next</span></a></table></div></div><center><br clear=all><br><table border=0 cellpadding=0 cellspacing=0 width=100% class="ft t bb bt"><tr><td align=center> <br><table border=0 cellpadding=0 cellspacing=0 align=center><form method=GET action="/images"><tr><td nowrap>
<font size=-1><input type=text name=q size=41 maxlength=2048 value="taz" title=""> <input type=submit name="btnG" value="Search Images"> <input type=submit name="btnmeta=search=search" value="Search the Web"><input type=hidden name=um value=1><input type=hidden name=hl value="en"><input type=hidden name=client value="firefox-a"><input type=hidden name=rls value="org.mozilla:en-US:official"><input type=hidden name=sa value="2"></font></td></tr></form></table><br></td></tr></table></center><center><p><hr class=z><div style="padding:2px" class=""><font size=-1>©2008 Google - <a href="http://www.google.com.br/">Google Home</a> - <a href="/intl/en/ads/">Advertising Programs</a> - <a href="http://www.google.com.br/intl/en/about.html">About Google</a></font></div><br></center></body></html>

 

TODO/Brainstorm

- use http://www.php.net/gzdeflate to try and uncompress the response (not sure how it will treat the plaintext/non-compressed data)

 

- find out if changing referrer/browser data helps stopping them from blocking consecutive requests (although in your scenario its unlikely you would spam requests like i just did while i was testing)

 

thats about it... i checked and there is no "im feeling lucky" image search and minimum results is 10 so that doesnt help either.

 

but still it wont be hard (just time consuming and ive got a lot on my hands right now!) to isolate the first image and then optimize (add an offset because most css/jss is the same length) to increase efficiency, etc)

 

- as for the resizing thats easily accomplished with the GD library (default package) - in fact if you search for "image resize" or maybe it was "image upload" or just look at my recent posts i already showed someone else how to do this using a 3rd party GPL-licensed class)

 

- and saving to a directory is easy too

 

i spent some time at the code of google pictures and this is what I found out:

if i want to get the link of the first picture, i have to select the second link, which starts with "http://" and ends with "jpg, png, tiff or whatever".

 

if you take a quick look at the RESPONSE DUMP above i think you'll agree that the best way to single out the pictures is by isolating the first result <td> which has a unique and "constant between searches" id = "tDataImage0"

 

*correction: resizing and manipulating GIF AND JPG is easy, PNG im not sure youre gonna have to look at the GD docs but i think you can only upload and download but not actually manipulate it.

and as for TIFFs i have no clue.

 

- and either way this is a pretty big project (i had initially only read the first few lines of your post and was meaning to do something similar in another context so i decided to dive right in)

 

so anyway, you now know that it IS posible, quite doable (except for maybe PNG/TIFF resizing) but this is either something that you could use as a great learning experience or probably something for the freelance forum instead :)

 

hope i was able to help you out!

 

-Alex

So I worked this night on a skript to get the link of the first picture of google pictures automatic. And it works !

Here it is:

<?
$link = "http://images.google.at/images?hl=de&q=[b]$searchtag[/b]&btnG=Bilder-Suche&gbv=1";
$code = file_get_contents($link,'r');

ereg ("imgurl=http://www.[A-Za-z0-9-]*.[A-Za-z]*[^.]*.[A-Za-z]*", $code, $img);

ereg ("http://(.*)", $img[0], $img_pic);

echo $img_pic[0];

?> 

 

 

  • 4 years later...

Yeah, you can't scrape Google pages.  

 

Don’t misuse our Services. For example, don’t interfere with our Services or try to access them using a method other than the interface and the instructions that we provide.

 

You have to use an interface that they provide.  The good thing is, that they provide an API for that. Custom Search API.

  • 2 months later...

Im trying tu use image google image-search from https://developers.google.com/image-search/v1/

But the code dont works.

You can see in my test page: www.netbooks.pt/teste.php

the image dont apears

 

 

Before I was using this code, but since a week that will not work:
 $jsonurl = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=".$row_rsProdutos['referencia'];
                 $result = json_decode(file_get_contents($jsonurl), true);
                 echo "<img height=\"200\" src='{$result['responseData']['results'][0]['tbUrl']}' />";
				 echo $row_rsProdutos['referencia'];
				 echo "<br/>";
                 $mensagem=' *A imagem pode n&atildeo corresponder ao produto.';
				 echo $mensagem;
someone can give me a hand?
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.