Hack Forums
[.NET] Websource sorting issue - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Websource sorting issue (/showthread.php?tid=4420542)



Websource sorting issue - NitroSmily - Aug 29, 2014

Hey guys, I've started a new project. I've completed the Probux Ad Viewer and I need some help with this. Basicly for each class called "lolz" I need to check if it has a picture url that contains "money". The first code you see below is how I've sort of got it to the point where I need to get the url of a picture.
The last code is from the site. I'd really appreciate some help and thank you for your time!
Code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim theElementCollection As HtmlElementCollection = Nothing
        theElementCollection = WebBrowser1.Document.GetElementsByTagName("div")
        For Each curElement As HtmlElement In theElementCollection
            If InStr(curElement.GetAttribute("classname").ToString, "lolz") Then



            End If
        Next
    End Sub
Code
<div class="lolz" style="float: right; background: url('hidden')"><img src="money.png" style="position: relative; left: -40px; top: -12px;"></div>



* - Haru9 - Aug 29, 2014

Do you mean something like this? 🙂
Code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      For Each curElement As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
      If curElement.GetAttribute("classname").Contains("lolz") Then
            Dim curElementImg As HtmlElementCollection = curElement.GetElementsByTagName("img")
            If curElementImg.Count = 1 Then : If curElementImg.Item(0).GetAttribute("src").Contains("money") Then
            'some code
            End If : End If
      End If
      Next
End Sub



* - NitroSmily - Aug 29, 2014

(Aug 29, 2014 11:07 AM)Haru9 Wrote:  Do you mean something like this? 🙂
Code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      For Each curElement As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
      If curElement.GetAttribute("classname").Contains("lolz") Then
      Dim curElementImg As HtmlElementCollection = curElement.GetElementsByTagName("img")
      If curElementImg.Count = 1 Then : If curElementImg.Item(0).GetAttribute("src").Contains("money") Then
      'some code
      End If : End If
      End If
      Next
End Sub
I tried and didn't get any results changing lines here and there, but I've changed method and now I need to search for a word in a richtextbox then retrieve the the entire line.
I thumbled and stopped when I got this:
Quote: For Each Line As String In RichTextBox2.Lines
If (Line.ToString = "Lolz") Then
ListBox1.Items.Add(Line)
End If
Next




* - Haru9 - Aug 30, 2014

Code
For Each Line As String In RichTextBox2.Lines
      If (Line.ToLower.Contains("Lolz".ToLower)) Then
      ListBox1.Items.Add(Line)
      End If
Next
or
Code
Dim line_number As Integer = RichTextBox2.GetLineFromCharIndex(RichTextBox2.Find("Lolz"))
Dim line As String = RichTextBox2.Lines(line_number)
ListBox1.Items.Add(line)