2 Replies - 8685 Views - Last Post: 28 March 2008 - 07:33 AM Rate Topic: -----

#1 Yeoj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 22-November 05

Extracting Images from HTML

Posted 28 March 2008 - 04:06 AM

I am trying to create an app that will extract all the results from a google image search consisting of keywords that the user defined. I got to the point where the user may enter their queries and the page will display in a web browser, but I really would like the images to be displayed only. This would be easy if the links remained the same, but obviously it varies from search to search. Therefore, i must download and/or display all images on the page, not including the google logo image (http://images.google.com/images/nav_logo3.png) How can i achieve this?

I would post what code i have now, but i really have no idea how to begin this concept. Any tips would be much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Extracting Images from HTML

#2 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: Extracting Images from HTML

Posted 28 March 2008 - 05:58 AM

so if you are using http://www.google.com to search in your code change that to http://images.google.com that should take you right to the images page
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1637
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Extracting Images from HTML

Posted 28 March 2008 - 07:33 AM

You could also use Regular Expressions to find and parse all <img tags, something like


public string DisplayImage(string source)
{
      string imgSource = string.Empty;
      string pattern = @"<img[^>]*src="([^"]*)"[^>]*>@Usi";
      RegEx check = New RegEx();
      if(RegEx.IsMatch(source,pattern))
      {
               imgSrc = RexEx.Split(source,pattern);
               return imgSrc;
       }
}




That example returns just a single image, for multiple images you're going to want to loop through each match and add them to a string array (or Hashtable or ArrayList, etc) then return that

This post has been edited by PsychoCoder: 28 March 2008 - 07:34 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1