Pushok

Bash parser

May 13th, 2011
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1.  
  2. namespace ParserBash
  3. {
  4.     public partial class Form1 : Form
  5.     {
  6.         public Form1()
  7.         {
  8.             InitializeComponent();
  9.         }
  10.  
  11.         private string StringRepeat(char Ch, int Rep)
  12.         {
  13.             string Str = null;
  14.  
  15.             for(int i=0;i<Rep;i++)
  16.                 Str += Ch;
  17.  
  18.             return Str;
  19.         }
  20.  
  21.         private void OnFormLoaded(object sender, EventArgs e)
  22.         {
  23.             WebRequest Request = WebRequest.Create(@"http://bash.org.ru/rss/");
  24.             StreamReader StrReader = new StreamReader(Request.GetResponse().GetResponseStream(), Encoding.GetEncoding(1251));
  25.             string text = StrReader.ReadToEnd();
  26.  
  27.             foreach(string str in text.Split(new string[] {"<item>", "</item>"}, StringSplitOptions.None))
  28.             {
  29.                 if (str.Contains(@"http://bash.org.ru/quote/"))
  30.                 {
  31.                     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";
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment