Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Imports System.Text
- Imports System.Text.RegularExpressions
- Imports System.IO
- Imports System.Runtime.InteropServices
- Public Class RankChecker
- Private Sub RankChecker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- If MyKeyword.Checked = True Then
- Keyword.Enabled = False
- Add.Enabled = True
- NewKeyword.Enabled = True
- MyKw.Enabled = True
- ClearAll.Enabled = True
- ClearSelected.Enabled = True
- End If
- If Custom.Checked = True Then
- Keyword.Enabled = True
- Add.Enabled = False
- NewKeyword.Enabled = False
- MyKw.Enabled = False
- ClearAll.Enabled = False
- ClearSelected.Enabled = False
- End If
- If Not My.Settings.Keywords = "" Then
- Dim K As String() = My.Settings.Keywords.Split(":")
- Dim f As Integer = K(0)
- For i = 0 To f - 1
- MyKw.Items.Add(K(i + 1))
- Next
- End If
- For Each row As DataGridViewRow In Form1.Stats.Rows
- Dim r As String
- r = row.Cells(0).Value
- Video.Items.Add(r)
- Next
- Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
- End Sub
- Private Sub Check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Check.Click
- If Not Video.SelectedItem = Nothing Then
- Dim thread As New Threading.Thread(AddressOf CheckIt)
- thread.Start()
- Else
- MsgBox("Please select the video!")
- Exit Sub
- End If
- End Sub
- Sub CheckIt()
- Dim query As String
- If Custom.Checked = True Then
- If Keyword.Text = "" Then
- MsgBox("Please write custom keyword!")
- Exit Sub
- End If
- query = Keyword.Text
- End If
- If MyKeyword.Checked = True Then
- If MyKw.Items.Count = 0 Then
- MsgBox("Please add some keywords!")
- Exit Sub
- End If
- If MyKw.SelectedItem = Nothing Then
- MsgBox("Please select the keyword!")
- Exit Sub
- Else
- query = MyKw.SelectedItem
- End If
- End If
- Status.Text = "Status: Checking..."
- Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
- query = query.Replace(" ", "+")
- Dim n As Integer = 0
- Dim vid As String = Video.SelectedItem
- For i = 0 To 29
- Dim inStream As StreamReader
- Dim WebRequest As WebRequest
- Dim Webresponse As WebResponse
- Dim Data As String
- n = n + 1
- WebRequest = WebRequest.Create("http://youtube.com/results?search_query=" & query & "&page=" & n)
- Webresponse = WebRequest.GetResponse()
- inStream = New StreamReader(Webresponse.GetResponseStream())
- Data = inStream.ReadToEnd()
- If Data.Contains(vid) Then
- Status.Text = "Video found on page " & n & "."
- Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
- Exit For
- End If
- If n >= 30 And Not Data.Contains(vid) Then
- Status.Text = "Video not found in first 30 pages, process stopped."
- Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
- Exit For
- End If
- If Not Data.Contains("<span class=""yt-uix-button-content"">Next") And Not Data.Contains(vid) Then
- Status.Text = "Video not found at all."
- Status.Location = New Point((Me.Width / 2) - (Status.Width / 2 + 10), Status.Location.Y)
- Exit For
- End If
- Next
- End Sub
- Private Sub Custom_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Custom.CheckedChanged
- If Custom.Checked = True Then
- Keyword.Enabled = True
- Add.Enabled = False
- NewKeyword.Enabled = False
- MyKw.Enabled = False
- ClearAll.Enabled = False
- ClearSelected.Enabled = False
- End If
- End Sub
- Private Sub MyKeyword_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyKeyword.CheckedChanged
- If MyKeyword.Checked = True Then
- Keyword.Enabled = False
- Add.Enabled = True
- NewKeyword.Enabled = True
- MyKw.Enabled = True
- ClearAll.Enabled = True
- ClearSelected.Enabled = True
- End If
- End Sub
- Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
- If Not NewKeyword.Text = "" Then
- MyKw.Items.Add(NewKeyword.Text)
- Else
- Exit Sub
- End If
- Create()
- End Sub
- Private Sub ClearSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearSelected.Click
- If MyKw.Items.Count = 0 Then
- MsgBox("Please add some keywords!")
- Exit Sub
- End If
- If MyKw.SelectedItem = Nothing Then
- MsgBox("Please select the keyword!")
- Exit Sub
- Else
- MyKw.Items.Remove(MyKw.SelectedItem)
- End If
- MyKw.Text = "Select my keyword..."
- Create()
- End Sub
- Private Sub ClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearAll.Click
- If MyKw.Items.Count = 0 Then
- MsgBox("Please add some keywords!")
- Exit Sub
- Else
- MyKw.Items.Clear()
- End If
- MyKw.Text = "Select my keyword..."
- Create()
- End Sub
- Sub Create()
- If Not MyKw.Items.Count = 0 Then
- Dim MKeywords As String = MyKw.Items.Count
- For Each item In MyKw.Items
- MKeywords = MKeywords & ":" & item
- Next
- My.Settings.Keywords = MKeywords
- Else
- My.Settings.Keywords = ""
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement