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.
Extracting Images from HTML
Page 1 of 12 Replies - 7114 Views - Last Post: 28 March 2008 - 07:33 AM
Replies To: Extracting Images from HTML
#2
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
#3
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
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
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
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|