[Visual Basic] New Project Read Posted RSS Blogger



Get RSS
Read Posted RSS
Etc...

Cập nhật thêm một số tính năng mới... !!!

Source Code (Tiến Trình Hoàn Thành Được 50%)

Imports System.Xml
Imports System.Xml.XPath
Imports System.Net
Imports System.IO
Imports System.Text.RegularExpressions


Public Class Form1
Private mRssUrl As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try

' set the file path member var
mRssUrl = LinkGetRss.Text

' Clear the treeview.
listlink.Items.Clear()
listtitle.Items.Clear()

' set the wait cursor
Me.Cursor = Cursors.WaitCursor

' create a new xml doc
Dim doc As New XmlDocument()

Try

' load the xml doc
doc.Load(mRssUrl)

' return the cursor
Me.Cursor = Cursors.Default

Catch ex1 As Exception

' return the cursor
Me.Cursor = Cursors.Default

' tell a story
MessageBox.Show(ex1.Message)
Return

End Try



' get an xpath navigator
Dim navigator As XPathNavigator = doc.CreateNavigator()

Try

' look for the path to the rss item titles navigate
' through the nodes to get all titles
Dim nodes As XPathNodeIterator = navigator.Select("/rss/channel/item/title")

While nodes.MoveNext

' clean up the text for display
Dim node As XPathNavigator = nodes.Current
Dim tmp As String = node.Value.Trim()
tmp = tmp.Replace(ControlChars.CrLf, "")
tmp = tmp.Replace(ControlChars.Lf, "")
tmp = tmp.Replace(ControlChars.Cr, "")
tmp = tmp.Replace(ControlChars.FormFeed, "")
tmp = tmp.Replace(ControlChars.NewLine, "")

' add a new treeview node for this
' news item title
listtitle.Items.Add(tmp)


End While


' set a position counter
Dim position As Integer = 0

' Get the links from the RSS feed
Dim nodesLink As XPathNodeIterator = navigator.Select("/rss/channel/item/link")

While nodesLink.MoveNext

' clean up the link
Dim node As XPathNavigator = nodesLink.Current
Dim tmp As String = node.Value.Trim()
tmp = tmp.Replace(ControlChars.CrLf, "")
tmp = tmp.Replace(ControlChars.Lf, "")
tmp = tmp.Replace(ControlChars.Cr, "")
tmp = tmp.Replace(ControlChars.FormFeed, "")
tmp = tmp.Replace(ControlChars.NewLine, "")


' use the position counter
' to add a link child node
' to each news item title
listlink.Items.Add(tmp)
listlink.SelectedItem = listlink.Items.Item(0)
listtitle.SelectedItem = listtitle.Items.Item(0)
'listlink.SelectedItem = listlink.Items.Item(0)

' increment the position counter

position += 1
Label2.Text = listlink.Items.Count

End While


Catch ex As Exception

MessageBox.Show(ex.Message, "RSS Feed Load Error")

End Try


' restore the cursor
Me.Cursor = Cursors.Default

Catch ex2 As Exception

' snitch
MessageBox.Show(ex2.ToString(), "RSS Feed Initialization Failure")
End Try
End Sub

Private Sub listlink_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listlink.SelectedIndexChanged
WebBrowser1.Navigate(listlink.SelectedItem.ToString())
End Sub

Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
'Progressbar hiển thị thời gian
ProgressBar1.Maximum = e.MaximumProgress
If e.CurrentProgress > ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Maximum
ElseIf e.CurrentProgress < ProgressBar1.Minimum Then
ProgressBar1.Value = ProgressBar1.Minimum
Else
ProgressBar1.Value = e.CurrentProgress

End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Text = "Tweet APP Viewer By Bờm Khùng" & Space(1) & ":" & DateTime.Now.ToLongTimeString.ToString()
TextBox4.Text = TextBox1.Text + 1
WebBrowser2.Navigate(TextBox2.Text)
'hàm selected listbox theo thứ tự
Try
TextBox1.Text = TextBox1.Text + 1
If TextBox1.Text < listlink.Items.Count Then
listlink.SelectedItem = listlink.Items.Item(TextBox1.Text)
ElseIf TextBox1.Text > listlink.Items.Count - 1 Then
listlink.SelectedItem = listlink.Items.Item(0)
End If

TextBox3.Text = TextBox3.Text + 1
If TextBox3.Text < listtitle.Items.Count Then
listtitle.SelectedItem = listtitle.Items.Item(TextBox3.Text)
ElseIf TextBox3.Text > listtitle.Items.Count - 1 Then
listtitle.SelectedItem = listtitle.Items.Item(0)
End If

'in lên textbox
TextBox2.Text = listtitle.SelectedItem + Space(1) & "=>" & Space(1) & listlink.SelectedItem + Space(1) & " => " & Space(1) & DateTime.Now.ToLongTimeString.ToString()

'in lên groupbox
GroupBox1.Text = listtitle.SelectedItem

'Hàm get ở webbrowser1 để post vào textarea trên web
Dim htmlElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
For Each el As HtmlElement In htmlElements

If el.GetAttribute("name").Equals("tweet[text]") Then
End If
el.SetAttribute("Value", TextBox2.Text + Space(1) & " => " & DateTime.Now.ToLongTimeString.ToString())

Dim allelements1 As HtmlElementCollection = WebBrowser1.Document.All

For Each webpageelement As HtmlElement In allelements1

If webpageelement.GetAttribute("value") = "Tweet" Then

webpageelement.InvokeMember("click")
End If
Next
Next

WebBrowser1.Navigate("https://mobile.twitter.com/compose/tweet")

Catch ex As Exception
Timer2.Start()
End Try
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Try

Dim htmlElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
For Each el As HtmlElement In htmlElements

If el.GetAttribute("name").Equals("tweet[text]") Then
End If
el.SetAttribute("Value", TextBox2.Text + DateTime.Now.ToLongTimeString.ToString())

Dim allelements1 As HtmlElementCollection = WebBrowser1.Document.All

For Each webpageelement As HtmlElement In allelements1

If webpageelement.GetAttribute("value") = "Tweet" Then

webpageelement.InvokeMember("click")
End If
Next
Next
WebBrowser1.Navigate("https://mobile.twitter.com/compose/tweet")

Catch ex As Exception
Timer1.Stop()
Timer2.Stop()
End Try
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Timer1.Start()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Timer1.Stop()
End Sub
End Class

Mình sẽ sớm hoàn thiện ứng dụng này trong một ngày không xa và rất xa !!!




Cập nhật thêm video cho mọi người :)