Results 1 to 2 of 2

Thread: WebClient Class

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Location
    Glasgow, Scotland
    Posts
    71

    WebClient Class

    Hi,

    I have a .net windows application and I need to open a web page (asp page), the page only returns one word at the top left of the page. I need to read the one word it returns within my windows applicaiton code. I understand that I can use the webclient class but do not know which method to use to return the text on the web page.

    Thanks for any help,

    Chris

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    if the page only displays a small amount of content and your sure it's not likely to change radically you could use a screen scrape and parse the HTML .

    OK this is in C# (and it's a bit of hack) but it's what i had handy in my clipboard and you get the idea...

    PHP Code:

    WebRequest myRequest 
    WebRequest.Create("http://<some address here>");
            
    WebResponse myResponse myRequest.GetResponse();

                

    System.IO.StreamReader sr = new System.IO.StreamReader(myResponse.GetResponseStream(),System.Text.Encoding.ASCII,true);

    //Just to display - parse the stream where you know your content will appear
    MessageBox.Show(sr.ReadToEnd().ToString());

    myResponse.Close(); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width