Author: aspquestion | Posted on: 11/29/2009 10:48:36 AM | Views : 222

Hello
 
There is a remote search engine that I want to scrap by my asp page.
I want to post searck keword to the remote site and retrive the resulting page.
I habe been advised to use the following code but it is not working.
 
public static string HttpPostRequest(string url, string post)
{
  var encoding = new ASCIIEncoding();
  byte[] data = encoding.GetBytes(post);
  WebRequest request = WebRequest.Create(url);
  request.Method = "POST";
  request.ContentType = "application/x-www-form-urlencoded";
  request.ContentLength = data.Length;
  Stream stream = request.GetRequestStream();
  stream.Write(data, 0, data.Length);
  stream.Close();
  WebResponse response = request.GetResponse();
  String result;
  using (var sr = new StreamReader(response.GetResponseStream()))
  {
Go to the complete details ...