HttpWebRequest simulate Firefox issue
Right now I use this code to simulate firefox:
var myUri = new Uri("http://www.google.com/search%3Fq%3Dyamaha");
// Create a 'HttpWebRequest' object for the specified url.
var myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
// Set the user agent as if we were a web browser
myHttpWebRequest.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4";
var myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
var stream = myHttpWebResponse.GetResponseStream();
var reader = new StreamReader(stream);
html = reader.ReadToEnd();
// Release resources of response object.
myHttpWebResponse.Close();
But I'm sure that this is not the best implementation, because I see
different results in Firefox and in my code response.
Question:
What is the best implementation of Mozilla Firefox (so google will think
that it's not my custom request, but request of Firefox) with
HttpWebRequest or System.Windows.Forms.WebBrowser (no matter what to use,
the best way please, if it's exist ).
Thank you in advance!
No comments:
Post a Comment