Question Need some help - facebook group helper [small things to fix]

Kathie Wendler

New member
Joined
Sep 5, 2011
Messages
1
Location
Bloomington, Indiana, United States
Programming Experience
1-3
Hello, i would like to create a small tool that filters new and old facebook groups, i am almost finished, but one part isnt working.. the filtering

here is the source code, grabbing groups works but checking if they are old or new doesn't, even though it should. There is one more feature not working where it filters the members size it is not grabbing the text it should (instead of grabbing the amount of members its just grabbing something from the beginning of the source code)

I would appreciate every help! :)

VB.NET:
Public Class Form1
    Public Function midReturn(ByRef total As String, ByVal first As String, ByVal last As String)
        Dim FirstStart As Short = total.IndexOf(first) + first.Length + 1
        Return Trim(Mid$(total, FirstStart, total.Substring(FirstStart).IndexOf(last) + 1))


    End Function


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Enabled = True
        Button4.Enabled = True
        CheckedListBox1.Visible = True
        CheckedListBox1.Enabled = True
        TextBox3.Visible = False
        WebBrowser1.Visible = False
        Button3.Visible = False
        Button2.Text = "Logged in"
        Button2.Enabled = False
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub

    Public Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Button1.Enabled = True
        OpenFileDialog1.InitialDirectory = "C:\"
        OpenFileDialog1.Title = "Pick your keywords list"
        OpenFileDialog1.ShowDialog()
        TextBox1.Text = OpenFileDialog1.FileName()
       
    End Sub

    Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim line As String
        Using reader As System.IO.StreamReader = New System.IO.StreamReader(OpenFileDialog1.FileName)
            line = reader.ReadLine
            While (line <> "")


                Dim request As System.Net.HttpWebRequest =  System.Net.HttpWebRequest.Create("http://www.facebook.com/search.php?q="  + line + "&type=groups")
                request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0) Gecko/20100101 Firefox/7.0"

                Dim response As System.Net.HttpWebResponse = request.GetResponse()

                Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

                Dim sourcecode As String = sr.ReadToEnd()


                Dim count2 = 0
                While (count2 < 20)



                    Dim var1 = "http://www.facebook.com/group.php?gid="
                    Dim var2 = " "
                    Dim arr = midReturn(sourcecode, var1, var2)
                    arr.Remove(arr.Length - 1, 1)

                    var1 = "is_friend":false});" & Chr(34) & ">"
                    var2 = "</a></div>"
                    Dim gname = midReturn(sourcecode, var1, var2)

                    Dim split = System.Text.RegularExpressions.Regex.Split(sourcecode, var2)
                    split(0) = ""
                    sourcecode = String.Join(var2, split)
                    sourcecode = sourcecode.Remove(0, 10)
                    var1 = "is_friend":false});" & Chr(34) & ">"
                    var2 = "</a></div>"
                    Dim members = midReturn(sourcecode, var1, var2)
                    split = System.Text.RegularExpressions.Regex.Split(sourcecode, var2)
                    split(0) = ""
                    sourcecode = String.Join(var2, split)
                    sourcecode = sourcecode.Remove(1, 10)

                    CheckedListBox1.Items.Add("Name: " + gname + " | " +  "URL: http://www.facebook.com/group.php?gid" + arr + " | " + members)

                    count2 = count2 + 1

                End While
                line = reader.ReadLine

            End While

        End Using
        Dim count = 1
        While (count < CheckedListBox1.Items.Count())
            Dim text As String = CheckedListBox1.Items.Item(count).ToString()
            Dim it = Split(text, "|")
            Dim url = it(1)
            url = url.Remove(1, 5)
            WebBrowser1.Navigate(url)
            Dim source As String = WebBrowser1.DocumentText
            If CheckBox1.Checked = True Then
                If source.Contains("This group is scheduled to be archived") Then
                    CheckedListBox1.Items.Remove(count)
                    GoTo ende
                End If
            Else
                If source.Contains("This group is scheduled to be archived") Then
                    CheckedListBox1.Items(count) = CheckedListBox1.Items(count) + " | OLD GROUP"
                Else
                    CheckedListBox1.Items(count) = CheckedListBox1.Items(count) + " | NEW GROUP"
                End If
            End If


            If CheckBox3.Checked = True Then
                Dim var1 As String = "class=\" & Chr(34) & "uiHeaderTitle\" & Chr(34) & ">Members ("
                Dim var2 As String = ")"
                Dim members As Integer = midReturn(source, var1, var2)
                If (members > 5000) Then
                    CheckedListBox1.Items.Remove(count)
                    GoTo ende

                End If

            End If

            If CheckBox2.Checked = True Then
                If source.Contains("Ask to Join Group") Then

                    CheckedListBox1.Items.Remove(count)
                    GoTo ende
                End If
            Else
                If source.Contains("Ask to Join Group") Then

                    CheckedListBox1.Items(count) = CheckedListBox1.Items(count) + " | Ask to join only"
                Else

                    CheckedListBox1.Items(count) = CheckedListBox1.Items(count) + " | Join now"
                End If
            End If
            count = count + 1
ende:
        End While
        CheckedListBox1.Update()
    End Sub

End Class
 
Please don't create multiple threads for the same topic. If you have posted to the wrong forum, please notify the moderators and they will move it for you. Your other thread on this topic has been deleted.
 
Back
Top