Advertisement
Guest User

Untitled

a guest
Nov 4th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Text
  3. Imports System.Text.RegularExpressions
  4. Imports System.IO
  5. Imports System.Runtime.InteropServices
  6.  
  7. Public Class RankChecker
  8.  
  9. Private Sub RankChecker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  10. If MyKeyword.Checked = True Then
  11. Keyword.Enabled = False
  12. Add.Enabled = True
  13. NewKeyword.Enabled = True
  14. MyKw.Enabled = True
  15. ClearAll.Enabled = True
  16. ClearSelected.Enabled = True
  17. End If
  18.  
  19. If Custom.Checked = True Then
  20. Keyword.Enabled = True
  21. Add.Enabled = False
  22. NewKeyword.Enabled = False
  23. MyKw.Enabled = False
  24. ClearAll.Enabled = False
  25. ClearSelected.Enabled = False
  26. End If
  27.  
  28. If Not My.Settings.Keywords = "" Then
  29. Dim K As String() = My.Settings.Keywords.Split(":")
  30. Dim f As Integer = K(0)
  31. For i = 0 To f - 1
  32. MyKw.Items.Add(K(i + 1))
  33. Next
  34. End If
  35. For Each row As DataGridViewRow In Form1.Stats.Rows
  36. Dim r As String
  37. r = row.Cells(0).Value
  38. Video.Items.Add(r)
  39. Next
  40. Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
  41. End Sub
  42.  
  43. Private Sub Check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Check.Click
  44. If Not Video.SelectedItem = Nothing Then
  45. Dim thread As New Threading.Thread(AddressOf CheckIt)
  46. thread.Start()
  47. Else
  48. MsgBox("Please select the video!")
  49. Exit Sub
  50. End If
  51. End Sub
  52.  
  53. Sub CheckIt()
  54. Dim query As String
  55.  
  56. If Custom.Checked = True Then
  57. If Keyword.Text = "" Then
  58. MsgBox("Please write custom keyword!")
  59. Exit Sub
  60. End If
  61. query = Keyword.Text
  62. End If
  63.  
  64. If MyKeyword.Checked = True Then
  65. If MyKw.Items.Count = 0 Then
  66. MsgBox("Please add some keywords!")
  67. Exit Sub
  68. End If
  69. If MyKw.SelectedItem = Nothing Then
  70. MsgBox("Please select the keyword!")
  71. Exit Sub
  72. Else
  73. query = MyKw.SelectedItem
  74. End If
  75. End If
  76.  
  77. Status.Text = "Status: Checking..."
  78. Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
  79.  
  80. query = query.Replace(" ", "+")
  81. Dim n As Integer = 0
  82. Dim vid As String = Video.SelectedItem
  83.  
  84. For i = 0 To 29
  85. Dim inStream As StreamReader
  86. Dim WebRequest As WebRequest
  87. Dim Webresponse As WebResponse
  88. Dim Data As String
  89.  
  90. n = n + 1
  91.  
  92. WebRequest = WebRequest.Create("http://youtube.com/results?search_query=" & query & "&page=" & n)
  93. Webresponse = WebRequest.GetResponse()
  94. inStream = New StreamReader(Webresponse.GetResponseStream())
  95. Data = inStream.ReadToEnd()
  96.  
  97. If Data.Contains(vid) Then
  98. Status.Text = "Video found on page " & n & "."
  99. Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
  100. Exit For
  101. End If
  102.  
  103. If n >= 30 And Not Data.Contains(vid) Then
  104. Status.Text = "Video not found in first 30 pages, process stopped."
  105. Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
  106. Exit For
  107. End If
  108.  
  109. If Not Data.Contains("<span class=""yt-uix-button-content"">Next") And Not Data.Contains(vid) Then
  110. Status.Text = "Video not found at all."
  111. Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
  112. Exit For
  113. End If
  114. Next
  115. End Sub
  116.  
  117. Private Sub Custom_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Custom.CheckedChanged
  118. If Custom.Checked = True Then
  119. Keyword.Enabled = True
  120. Add.Enabled = False
  121. NewKeyword.Enabled = False
  122. MyKw.Enabled = False
  123. ClearAll.Enabled = False
  124. ClearSelected.Enabled = False
  125. End If
  126. End Sub
  127.  
  128. Private Sub MyKeyword_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyKeyword.CheckedChanged
  129. If MyKeyword.Checked = True Then
  130. Keyword.Enabled = False
  131. Add.Enabled = True
  132. NewKeyword.Enabled = True
  133. MyKw.Enabled = True
  134. ClearAll.Enabled = True
  135. ClearSelected.Enabled = True
  136. End If
  137. End Sub
  138.  
  139. Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
  140. If Not NewKeyword.Text = "" Then
  141. MyKw.Items.Add(NewKeyword.Text)
  142. Else
  143. Exit Sub
  144. End If
  145. Create()
  146. End Sub
  147.  
  148. Private Sub ClearSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearSelected.Click
  149. If MyKw.Items.Count = 0 Then
  150. MsgBox("Please add some keywords!")
  151. Exit Sub
  152. End If
  153. If MyKw.SelectedItem = Nothing Then
  154. MsgBox("Please select the keyword!")
  155. Exit Sub
  156. Else
  157. MyKw.Items.Remove(MyKw.SelectedItem)
  158. End If
  159. MyKw.Text = "Select my keyword..."
  160. Create()
  161. End Sub
  162.  
  163. Private Sub ClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearAll.Click
  164. If MyKw.Items.Count = 0 Then
  165. MsgBox("Please add some keywords!")
  166. Exit Sub
  167. Else
  168. MyKw.Items.Clear()
  169. End If
  170. MyKw.Text = "Select my keyword..."
  171. Create()
  172. End Sub
  173.  
  174. Sub Create()
  175. If Not MyKw.Items.Count = 0 Then
  176. Dim MKeywords As String = MyKw.Items.Count
  177. For Each item In MyKw.Items
  178. MKeywords = MKeywords & ":" & item
  179. Next
  180. My.Settings.Keywords = MKeywords
  181. Else
  182. My.Settings.Keywords = ""
  183. End If
  184. End Sub
  185. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement