1
Answer

image search given string using google url?

Prasad Bhagat

Prasad Bhagat

8y
271
1
Dear All,
 
 
here am working for google image search using google image url+our string
 
 
am getting the results perfect but am not getting the list of images with name,url of image like thing please have a look on it .kindly help me if any solution to me .
 
 
 
string searchstring = "http://images.google.com/images?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&q=";
string alternatesearch = "http://images.google.com/images?q=SEARCH&svnum=10&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&filter=0";
string resultpage = "";
string startoftable = "table align=center border=0 cellpadding=5 cellspacing=0";
string moreimglink = "http://images.google.com/images?q=SEARCH&svnum=10&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&start=SET&sa=N";
int seto20 = 0;
ArrayList thumbs = new ArrayList();
ArrayList googlethumbs = new ArrayList();
ArrayList links = new ArrayList();
ArrayList gtsizes = new ArrayList();
ArrayList labels = new ArrayList();
string searchtext = "";
 
 
 
private void search()
{
foreach (Label c in labels)
{
c.Image = null;
c.Visible = false;
c.Dispose();
}
Application.DoEvents();
System.GC.Collect();
Application.DoEvents();
System.GC.Collect();
googlethumbs = new ArrayList();
thumbs = new ArrayList();
links = new ArrayList();
gtsizes = new ArrayList();
WebClient WC = new WebClient();
byte[] data = null;
if (seto20 != 0)
data = WC.DownloadData(moreimglink.Replace("SEARCH", searchtext.Replace(" ", "+")).Replace("SET", seto20.ToString()));
else
data = WC.DownloadData(searchstring + textBox1.Text);
WC.Dispose();
System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding();
resultpage = AE.GetString(data, 0, data.Length);
resultpage = resultpage.Substring(resultpage.IndexOf(startoftable) + startoftable.Length);
try
{
resultpage = resultpage.Substring(0, resultpage.IndexOf("Result Page:&nbsp"));
}
catch (Exception e44)
{
e44 = e44;
WebClient Wc = new WebClient();
byte[] daTa = Wc.DownloadData(alternatesearch.Replace("SEARCH", textBox1.Text.Replace(" ", "+")));
Wc.Dispose();
System.Text.ASCIIEncoding Ae = new System.Text.ASCIIEncoding();
resultpage = Ae.GetString(daTa, 0, daTa.Length);
resultpage = resultpage.Substring(resultpage.IndexOf(startoftable) + startoftable.Length);
}
showIMGs();
parse();
//WriteToFile();
resultpage = null;
}
 
 
 
 
This is the code .
 
am getting a html data result perfect but am not getting the imagelist .please help me
am implementing this way because the google seach api now not a free .they are going to charge after 100 request .so am doing this .please help me
am using c# 
Answers (1)