how to use Screen Scraping(page) in asp.net

Last post 05-28-2007 1:54 AM by Jessica Cao - MSFT. 6 replies.

Sort Posts:

  • how to use Screen Scraping(page) in asp.net

    05-23-2007, 2:00 AM

    Hai

    i want ro screen scraping one page...

    in my asp html  code window one <asp:literal> or div tag

    i want screen scraped paged html source code dislayed in  the div tag or literal....

     

    please help me...

  • Re: how to use Screen Scraping(page) in asp.net

    05-23-2007, 2:46 AM
    • Loading...
    • Girijesh
    • Joined on 10-27-2005, 12:04 PM
    • India
    • Posts 638

     public string GetHtmlContent()
        {
            // the html retrieved from the page
            string strURL = @"http://www.domain.com/pagename.extension";
            String strResult;
            WebResponse objResponse;
            WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL);
            objResponse = objRequest.GetResponse();
            // the using keyword will automatically dispose the object
            // once complete
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr.ReadToEnd();
                // Close and clean up the StreamReader
                sr.Close();
            }
            return strResult;
        }

  • Re: how to use Screen Scraping(page) in asp.net

    05-23-2007, 2:52 AM
    How to read a remote web page with ASP.NET 2.0:http://www.mikesdotnetting.com/Article.aspx?ArticleID=49 
    Regards Mike
    [MVP - ASP/ASP.NET]
  • Re: how to use Screen Scraping(page) in asp.net

    05-24-2007, 5:25 AM

    Hai thanks for your reply..

     i want to pass the usename anad password.. to request web page..

    i want to content of the request logined page..

    please help me...

    i want to send the request url page with post information...

    please help me.. 

     

     

  • Re: how to use Screen Scraping(page) in asp.net

    05-24-2007, 11:00 PM

    thirunavukarasu:

    Hai thanks for your reply..

     i want to pass the usename anad password.. to request web page..

    i want to content of the request logined page..

    please help me...

    i want to send the request url page with post information...

    please help me.. 

    Hi thirunavukarasu,

     "i want to pass the usename anad password.. to request web page.." and "i want to send the request url page with post information..."

    I think the  two problems can be solved by transmit values from page to page, see this URL:

    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.button.postbackurl.aspx (PostBackUrl Property),

    And "i want to content of the request logined page..", you can refer Girijesh's code,

    Hope it helps,

    Hong Gang

     

     

     

     

     

    Sincerely,
    Hong-Gang Chen
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: how to use Screen Scraping(page) in asp.net

    05-25-2007, 12:55 AM

    Hai,,

    i want to post data with screen scrap page..

    i want  to send from to destination station  which class and date...

    i run the screenscrap.aspx page the posted data send to the request page with to display the posted page

    that is searched page..)

    here my code..

    ScrapPage.aspx....

    Public Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton.Click

    Dim RequestUrl  As String = "http://www.indianrail.gov.in/src_dest_trns.html"

    Dim Post As String = "lccp_src_stncode=" & "ms" & "lccp_dstn_stncode=" & "vpt" & "lccp_classopt=" & "SL" & "lccp_day=" & "27" & "lccp_month=" & "May"

     

    Dim Writer As StreamWriter = Nothing

    Dim WebRequestObject As HttpWebRequest

    Dim sr As StreamReader

    Dim WebResponseObject As HttpWebResponse

     

    Try

    WebRequestObject = CType(WebRequest.Create(RequestUrl), HttpWebRequest)

    WebRequestObject.Method = "POST"

    WebRequestObject.ContentType = "application/x-www-form-urlencoded"

    WebRequestObject.ContentLength = Post.Length

    Writer =
    New StreamWriter(WebRequestObject.GetRequestStream())

    Writer.Write(Post)

    Writer.Close()

    WebResponseObject = CType(WebRequestObject.GetResponse(), HttpWebResponse)

    sr = New StreamReader(WebResponseObject.GetResponseStream)Dim Results As String = sr.ReadToEnd

    WebResponseLabel.Text = Results

    WebResponseText.Text = Results

    Finally

    Try

    sr.Close()

    Catch

    End Try

    Try

    WebResponseObject.Close()

    WebRequestObject.Abort()

    Catch

    End Try

    End Try

     

    ----------------------------------------------

     <body MS_POSITIONING="GridLayout">
      <form id="Form1" method="post" runat="server">

    <asp:button id="SubmitButton" onclick="SubmitButton_Click" Text="Get IRTC Search Booked Tickets"
        Runat="server"></asp:button><br>
       <asp:textbox id="WebResponseText" Runat="server" TextMode="MultiLine" Height="300" Width="780"></asp:textbox><asp:label id="WebResponseLabel" Runat="server"></asp:label></form>
     </body>

     i want to post data to the request url to view posted page....

    please help me....
  • Re: how to use Screen Scraping(page) in asp.net

    05-28-2007, 1:54 AM
    Answer

    Hello,

    Please refer to this thread Screen Scraping with C# for ASP.NET

    Hope it helps,

    Jessica

    Jessica Cao
    Sincerely,
    Microsoft Online Community Support


    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Page 1 of 1 (7 items)
Microsoft Communities
Page view counter