Screen Scraping in ASP.NET which need Username and password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Monish30
    New Member
    • Mar 2010
    • 11

    Screen Scraping in ASP.NET which need Username and password

    hi i need to Screen scrape the smsze.com which required the login page. I need to scrape the page after login so what should i do..
    code is as below
    Code:
    string url = "http://www.smsze.com/logingo.php";         
     
                WebRequest request = WebRequest.Create(url);
     
                request.Method = "POST";
     
                string postData = "mobile=9998471231&pass=xyz&Submit='Sign In'";
     
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byteArray.Length;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
     
                WebResponse response = request.GetResponse();
                dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
     
                string responseFromServer = reader.ReadToEnd();
     
                richTextBox1.Text = responseFromServer;
    Can you tell me what to do... Pls give me example so that i can better understand. You can also mail me at <email snipped>
    Thanks in advance.
    Last edited by Frinavale; Mar 12 '10, 02:13 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags. Removed email address: please do not post your email address.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    The experts here on bytes are more than happy to give you a hand with a specific problem that you are having but it's unfair for you to ask a question as vague as "how do you write a program".

    The code you've posted looks like it should work...are you having any problems with it? If you are what is the problem? Are you getting any error messages? What have you tried to solve the problem?

    By the sounds of it you are able to download the content and all you need to do is parse through it and take what you need. In that case you will probably be interested in reading up on the XML Document Object Model (DOM) and maybe the XMLReader class.

    -Frinny

    Comment

    Working...