I'm trying to get the source code of google's Search by Image page. So, the Search by Image URL is https://www.images.google.com/searchbyimage?image_url=x x is the image URL.
I use that code, but the source code I get is the source code of google images, not the source code of the specific search result webpage.
public static string GetSourceCode(string url)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sr.Close();
myResponse.Close();
return result;
}
When you execute a Google Search, Google only returns a bit of HTML (which you see, when you open your result-string in a browser). The JavaScript, in your result, is run to load the actual search results.
As a side note, in Chrome (at least, that's where I have actually tested it) you can watch the JavaScript run, if you set a breakpoint at 'load'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.