Pushok icon

Bash parser

Pushok | PRO | 05/13/11 02:58:36 PM UTC | 0 ⭐ | 700 👁️ | Never ⏰ | []
C# |

1.21 KB

|

None

|

0 👍

/

0 👎

 
namespace ParserBash
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private string StringRepeat(char Ch, int Rep)
        {
            string Str = null;
 
            for(int i=0;i<Rep;i++)
                Str += Ch;
 
            return Str;
        }
 
        private void OnFormLoaded(object sender, EventArgs e)
        {
            WebRequest Request = WebRequest.Create(@"http://bash.org.ru/rss/");
            StreamReader StrReader = new StreamReader(Request.GetResponse().GetResponseStream(), Encoding.GetEncoding(1251));
            string text = StrReader.ReadToEnd();
 
            foreach(string str in text.Split(new string[] {"<item>", "</item>"}, StringSplitOptions.None))
            {
                if (str.Contains(@"http://bash.org.ru/quote/"))
                {
                    richTextBox1.Text += str.Split(new string[] { "<title>", "</title>" }, StringSplitOptions.None)[1] + "\n\n" + str.Split(new string[] { "<![CDATA[", "]]>" }, StringSplitOptions.None)[1].Replace("<br>", "\n").Replace("&quot;", "") + "\n" + StringRepeat('=',10) + "\n";
                }
            }
        }
    }
}

Comments