All pastes #908463 Raw Edit

Someone

public text v1 · immutable
·published 2008-02-18 14:29 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net.Sockets;
using System.Net;
using System.Text.RegularExpressions;


namespace webRequestform
{
    public partial class frmRequest : Form
    {
        public frmRequest()
        {
            InitializeComponent();
        }

        private void btnDoReq_Click(object sender, EventArgs e)
        {
            if((txtAddress.Text.StartsWith("http://"))==true && txtAddress.Text!=null){
            
            string html = null;
             HttpWebRequest request;
             HttpWebResponse response=null;
            try
             {
                 request = (HttpWebRequest)WebRequest.Create(txtAddress.Text);
                response = (HttpWebResponse)request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream(), true);
                 if (response.StatusCode > 0)
                 {
                     string line = "";
                     while (line != null)
                     {
                        line = reader.ReadLine();
                        html += line;
                     }

                     
                     
                     txtSource.Text = html.ToString();
                     
                 }
                 else
                 {
                     txtSource.Text = "Error Getting Page";
                 }
             }
             catch (System.IO.IOException ex)
             {
                 MessageBox.Show(ex.Message.ToString());
             }
             catch (System.Net.WebException ex)
             {
                 MessageBox.Show(ex.Message.ToString());
             }

            }else{
                MessageBox.Show("Wrong Address");
            }
            
        }

        private void frmRequest_Load(object sender, EventArgs e)
        {
            txtAddress.Text = "http://";

        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {

        }

        private void btnRetrieveLinks_Click(object sender, EventArgs e)
        {
            Regex r;
            Match m;
            r = new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))",
            RegexOptions.IgnoreCase | RegexOptions.Compiled);
            for (m = r.Match(txtSource.Text.ToString()); m.Success; m = m.NextMatch())
            {
                string strlink = m.Groups[1].ToString();
                lstLinks.Items.Add(strlink);

            }
        }
    }
}