Loading...
Logo
Processing Forum

Since two days I try to figure out how to download image from different news sites from the internet and start slowly to get crazy.

I would like to download Pictures mainly from news.google.com and to display them in a processing window. 

Does anybody know how to handle these problem? Help!

Replies(2)

Usual answer: what have you tried? What is your code? It is really simple, so we have to see your code to see what went wrong...

Note that Google and some other sites might not accept direct downloads from automated means (ie. not from a browser).

Thank You for the reply.


I tried to access the Google RSS Newsfeed with XML.


 rss         = new XMLElement(me, url);

 title       = rss.getChildren("channel/item");       

 link       = rss.getChildren("channel/item/link");


Unfortunately I was not able to get the pictures direct from Google, that's why I was looking for the Links to different News websites


Then I tried to search the Images on the HTML Code on these Websites.



void imgSearch(String addr){

  String [] htl = loadStrings (addr);

  String[] img = {

  };

  int indexof;

  for (int i=0; i< htl.length; i++){

    indexof = htl[i].indexOf("articlefeature");

    if (indexof > -1){

      if ( (htl[i].indexOf("<img src=") > -1) && (htl[i].indexOf(".jpg") > -1) ){

        String temp [] = split(htl[i], "<img src=");

        for (int j=0; j < temp.length; j++){

          if (temp[j].indexOf(".jpg")> -1){

            if (str(temp[j].charAt(0)).equals("\"")){

              temp[j] = temp[j].substring(1,temp[j].length());

            }

            String temptemp [] = split(temp[j], ".jpg");

            img = expand(img,img.length +1);

            img[img.length-1] = temptemp[0]+".jpg";

          }

        }

      }

    }

  }

  println(img);

  return(img);

}


These works on some News sites but on others it does not because the site structures of the websites are not always the same.


As you see these tries are very basic and not really suitable for my problem.