loading google image search result

Hello All,

I’m trying to load google image search result (one of the result) into the plane in the game.

Here’s the code:

        var query="http://images.google.com/images?q="+_name+"&hl=en&imgsz=Medium";
	wwwHtml= new WWW (query);
	
	var returnStr : String;

	yield wwwHtml;
	returnStr=wwwHtml.data;
	
	var startIndex=returnStr.IndexOf("imgres?imgurl=");
	returnStr=returnStr.Substring(startIndex+14);
	Debug.Log(returnStr);
	var endIndex=returnStr.IndexOf("imgrefurl");
	returnStr=returnStr.Substring(0,endIndex-1);
	Debug.Log(returnStr);
	yield LoadFoodImage(returnStr);

This works “most of times” but it sometimes fails due to the fact that although wwwHtml.isDone becomes true and yield statement ends, wwwHtml.data doesn’t have anything within it. This happens for particular words; for example I can query “food” without any issue, but “bush” only returns empty string.

What am I doing wrong?

btw, I also found out that result image in gif format is not correctly loaded this case(using www.texture). rather it only shows big red question mark. Is there way around this issue?

Not sure about the Google search thing, but as far as .gifs go, like the docs say: “The data must be an image in JPG or PNG format.”

–Eric

Thanks. surely gif format is allowed for www.texture loading.

For google search issue,

long story short, is there any chance that www.data is blank even though loading is done and isDone value is true? then what’s the case?

Thanks!

No…as the docs say, “The data must be an image in JPG or PNG format.” :slight_smile: No gif.

–Eric

oops that was typo. sorry. you’re right gif doens’t work.

Can i take a look demo?