We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › proHTML "file missing" error...
Page Index Toggle Pages: 1
proHTML "file missing" error... (Read 911 times)
proHTML "file missing" error...
Mar 16th, 2007, 1:10am
 
Hi!  I'd be very appreciative if someone could help me with this...
I'm using the proHTML library for the first time, to collect images from random myspace profile pages. This is really all the relevant code:

Code:
  
htmlImageFinder = new HtmlImageFinder(url);
imagesonpage = htmlImageFinder.getNumbOfImages();
if (imagesonpage > 1)
{
profileimage = loadImage(htmlImageFinder.getImageLink(1));
pics[counter] = profileimage;
}
else
{
pics[counter] = blank;
}


I define the "url" separately in another part of the code as "http://www.myspace.com/" + a randomly generated number.  And usually, this code works just fine.  But sometimes it hiccups with an error like the following:

Code:
The file "http://myspace-250.vo.llnwd.net/00000/05/22/32250_m.jpg" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable. 



Now from what I gather, that basically means that proHTML knows there's an image on the page, but when it tries to load the image, it finds out the image URL is for some reason broken, and then it shuts down.

My question is, is there any way to check for this problem and resolve it by diverting the program to a new URL?  Any help would be greatly appreciated!
-Katherine
Re: proHTML "file missing" error...
Reply #1 - Mar 16th, 2007, 8:37am
 
You're looking for try/catch. I think you've got an exception that you can catch in the catch block from where you can start a new search.
http://www.exampledepot.com/egs/Java%20Language/TryCatch.html?l=new

Quote:


try {
   // try to your imageload Image
} catch (ExceptionType name) {
   // if the image doesnt exist retry loading with another image
}



Re: proHTML "file missing" error...
Reply #2 - Mar 16th, 2007, 12:16pm
 
Ah, that looks like just what I needed!  Thank you very much for your help!
-Katherine
Page Index Toggle Pages: 1