Advertisement
Guest User

RSS POSTED FULL SOURCE

a guest
Sep 20th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.67 KB | None | 0 0
  1. Option Strict On
  2. Option Explicit On
  3.  
  4. Imports Microsoft.VisualBasic
  5. Imports System
  6. Imports System.Globalization
  7. Imports System.Net
  8. Imports System.Xml
  9. Imports System.IO
  10. Public Class Form1
  11.     Dim myRequest As WebRequest
  12.     Dim myResponse As WebResponse
  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14.         'link cần thay đổi để lấy dữ liệu của trang blog bạn cần.
  15.         Dim url As String = "http://www.hungcoder.com/feeds/posts/default"
  16.         Dim rssFeed As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
  17.         Dim response = rssFeed.GetResponse()
  18.         Dim rssStream = response.GetResponseStream()
  19.  
  20.         Dim rssDoc As New XmlDocument()
  21.         rssDoc.Load(rssStream)
  22.         Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item")
  23.         Dim i As Integer = 0
  24.         Dim dt As DataTable = New DataTable("table")
  25.         dt.Columns.Add("title", Type.GetType("System.String"))
  26.         dt.Columns.Add("link", Type.GetType("System.String"))
  27.  
  28.         While i < rssItems.Count
  29.             Dim node As XmlNode = rssItems.Item(i).SelectSingleNode("title")
  30.             Dim title As String
  31.             Dim link As String
  32.             If node IsNot Nothing Then
  33.                 title = node.InnerText
  34.             Else
  35.                 title = ""
  36.             End If
  37.  
  38.             node = rssItems.Item(i).SelectSingleNode("link")
  39.             If node IsNot Nothing Then
  40.                 link = node.InnerText
  41.             Else
  42.                 link = ""
  43.             End If
  44.             Dim dr As DataRow = dt.NewRow()
  45.             dr("title") = title
  46.             dr("link") = link
  47.  
  48.             dt.Rows.Add(dr)
  49.  
  50.             i += 1
  51.         End While
  52.  
  53.         DataGridView1.DataSource = dt
  54.         DataGridView1.Columns(1).Width = 900
  55.         DataGridView1.Columns(0).Width = 420
  56.     End Sub
  57.  
  58.     Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
  59.         Try
  60.             If Me.WindowState = FormWindowState.Minimized Then
  61.                 Me.Visible = False
  62.                 NotifyIcon1.Visible = True
  63.                 NotifyIcon1.ShowBalloonTip(1, "Thông Báo", "HungCoder.Com Đang Ẩn Nấp Tại Đây.", ToolTipIcon.Info)
  64.             End If
  65.         Catch ex As Exception
  66.             MsgBox(ex.Message)
  67.         End Try
  68.     End Sub
  69.     Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
  70.         Me.Show()
  71.         NotifyIcon1.ShowBalloonTip(500, "Thông Báo", "HungCoder.Com Đã Có Mặt.", ToolTipIcon.Info)
  72.     End Sub
  73.     Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  74.         Try
  75.             Me.Visible = True
  76.             Me.WindowState = FormWindowState.Normal
  77.             NotifyIcon1.Visible = False
  78.         Catch ex As Exception
  79.             MsgBox(ex.Message)
  80.         End Try
  81.     End Sub
  82.  
  83.     Private Sub AuthorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthorToolStripMenuItem.Click
  84.         Process.Start("https://www.hungcoder.com/p/about.html")
  85.     End Sub
  86.  
  87.     Private Sub MyBlogToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBlogToolStripMenuItem.Click
  88.         Process.Start("https://link.hungcoder.com/")
  89.     End Sub
  90.  
  91.     Private Sub FacebookToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FacebookToolStripMenuItem.Click
  92.         Process.Start("https://link.hungcoder.com/go/facebook")
  93.     End Sub
  94. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement