• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2026 Replies
  • 331 Replies
    1928 Replies

webbrowser help

Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
User avatar
Dummy1912
VIP - Donator
Posts: 1998

webbrowser help

Sat Oct 12, 2019 8:41 am

Hello,

like you may already known, i'm making a program for my work

how can i get those results in several labels?
and also the clickurl parts

these is a part of the original webpage

Code: Select all

<tbody>
<tr>
<td class="photothumb" style="width:100px"><img src="https://www.mywebsite.com//files/modules/products/64842/photos/thumb_IMG_0946.JPG" width="100" height="100"></td><td class="referentienr"><a href="https://www.mywebsite.com/folder/nl/orders/detail/64842">TV-19-064842</a></td><td class="artikelcode"><a href="https://www.mywebsite.com/nl/2-v/p/64842-vintage-table-lamp with-white-glass-milk-glass" target="_blank">0980</a></td><td class="title_nl">vintage table lamp with white glass milk glass</td><td class="endTime">2019-10-08 20:40:00</td><td class="winningUserId"><a href="https://www.mywebsite.com/folder/nl/clients/edit/1492">John the Fighter</a></td><td class="shippingMethod">Pick up</td><td class="Total amount">€ 21,20</td><td class="msrp">4.5</td><td class="failed"><img src="https://www.mywebsite.com/folder/templates/admin/images/false.png" title="no"></td><td class="onHold"><img src="https://www.mywebsite.com/folder/templates/admin/images/false.png" title="no"></td><td class="paymentReceived"><img src="https://www.mywebsite.com/folder/templates/admin/images/true.png" title="yes"></td><td class="shipped"><img src="https://www.mywebsite.com/folder/templates/admin/images/true.png" title="yes"></td><td class="retour"><img src="https://www.mywebsite.com/folder/templates/admin/images/false.png" title="no"></td><td class="completed"><img src="https://www.mywebsite.com/folder/templates/admin/images/true.png" title="yes"></td><td class="icon"><a href="https://www.mywebsite.com/folder/nl/orders/editAuction/64842" title="Edit"><img src="https://www.mywebsite.com/folder/templates/admin/images/icons/edit.png" alt="" title=""></a></td>			</tr>
'and here start the next record ect...
<tr><td class =
</tbody>
i like to get the part tr till td and to add image , text , urls into my textbox and the url in a linklabel
and how to get it into a loop because
there are a lot of records in the tbody part and start again with <tr><td class
i like to add them into panel.addcontrol(
so we get every record

on my form:
custom control with those controls:
i need the faild,onhold, paymentreceived,shipped,retour,completed into a checkbox
the linklabels are: edit, winningUserId, referentienr, artikelcode,
into a combox: pickup
into picturebox: photothumb
into a label : title_nl, endTime, Total amount, msrp



thank you
the other parts coming soon if we need you guys

User avatar
Dummy1912
VIP - Donator
Posts: 1998

Re: webbrowser help

Sun Oct 13, 2019 12:15 pm

hi guys,

so i came up with this so far

Code: Select all

        MsgBox(WebBrowser1.Document.GetElementsByTagName("table")(0).InnerText)
        MsgBox(WebBrowser1.Document.GetElementsByTagName("td")(1).InnerText)

i see the td(0) is empty thats the place of the image (how to get this in a picturebox)


i have several pages
i know i can search with this part

Code: Select all

 'search customer in textbox1
        Dim PageText As String
        For Each td In WebBrowser1.Document.GetElementsByTagName("td")
           If InStr(td.innertext, TextBox1.Text) > 0 Then
               PageText = td.innertext 
            End If
        Next
but i get only 1 result or 2 result in PageText depends how many customernames are on this page
but i like to get more results when we have more then 1 page

and how do i get this in a loop
and show only the customernames we are looking for and hide the rest on the page?

User avatar
Dummy1912
VIP - Donator
Posts: 1998

Re: webbrowser help

Sun Oct 13, 2019 5:10 pm

i also tried this

Code: Select all

Dim elements = Me.WebBrowser1.Document.GetElementsByTagName("td")

        If elements IsNot Nothing Then
            Dim items =
                (
                    From el
                    In elements.Cast(Of HtmlElement)()
                    Where el.InnerText <> String.Empty
                    Select el.InnerText
                )

            For index As Integer = 0 To items.ToArray.Count - 1
                Dim pnl As New Button
                With pnl
                    .Text = items(5) 'contains the name
                    .Dock = DockStyle.Top
                    .Refresh()
                End With
                Panel1.Controls.Add(pnl)
            Next
but i get only lots of records but with same customername and not different customernames
what do we wrong?

User avatar
Dummy1912
VIP - Donator
Posts: 1998

Re: webbrowser help

Sun Oct 13, 2019 6:21 pm

strange i can't edit my post...

okay i updated my code
but still i get a whole list but only with the same customer name
not with different names

Code: Select all

        Dim elements = Me.WebBrowser1.Document.GetElementsByTagName("td")
        Dim numResults As Integer = Me.WebBrowser1.Document.GetElementsByTagName("td").Count
        If elements IsNot Nothing Then
            Dim items =
                (
                    From el
                    In elements.Cast(Of HtmlElement)()
                    Where el.InnerText <> String.Empty
                    Select el.InnerText
                )

            For i As Integer = 1 To numResults - 1 Step 1
                If Not elements(i).InnerText Is Nothing Then
                    Dim pnl As New Button
                    With pnl
                        .Text = elements(1).InnerText & " " & elements(6).InnerText
                        .Dock = DockStyle.Top
                        .Refresh()
                    End With
                    Panel1.Controls.Add(pnl)
                End If
            Next
elements(6).InnerText is the customer name
with this code
elements(i).InnerText
i get all the records 1 so thats great
but i need to split them in 1 button later it will be a custombar but still
we are first testing all before next level :)

so i like to get 1 button with first customer
then next button the other customer
ect...

i get this
https://drive.google.com/open?id=1qcvoD ... tgFrsdznXo

and i want to get this
https://drive.google.com/open?id=1cx5Ka ... vJ4UlbR4Qv

User avatar
Dummy1912
VIP - Donator
Posts: 1998

Re: webbrowser help

Tue Oct 15, 2019 4:09 am

hi guys,

so far so good
we have managed to get the id and name of the customers :)

my next question will be
how do i get all the multipages like 1 2 3 4 5 ect...
to get with automatic click with my button (GetCustomerIDandNAME) to collected the id and name of the customers?
and check at once if not already exist in my button

to get my id and name of the customers

Code: Select all

    Sub GetCustomerIDandNAME()
            Dim i As Integer = 0
        For Each Link As HtmlElement In WebBrowser1.Document.Links

            For ii As Integer = 1 To 1 Step 1
                If Link.OuterHtml.Contains("/clients/edit/") Then
                    Dim btn As New Button


                    ''##Get Names
                    btn.Text = i & ". " & Link.OuterHtml
                    btn.Text = btn.Text.Remove(0, 67)
                    btn.Text = btn.Text.Replace("</A>", "")
                    btn.Text = btn.Text.Trim()
                    btn.Text = btn.Text.TrimStart()
                    btn.Text = btn.Text.TrimEnd()

                    Dim toRemove = New Char(14) {}
                    toRemove(0) = "1"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "2"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "3"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "4"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "5"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "6"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "7"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "8"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "9"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "0"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "<"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = "/"c
                    btn.Text = btn.Text.TrimStart(toRemove)
                    toRemove(0) = """"c
                    btn.Text = btn.Text.TrimStart(toRemove)

                    toRemove(0) = ">"c
                    btn.Text = btn.Text.TrimStart(toRemove)

                    str = btn.Text 'contains customer name
                    
                    

                    '###Get CustomerID
                    btn.Text = i & ". " & Link.OuterHtml
                    btn.Text = btn.Text.Remove(0, 63)
                    btn.Text = btn.Text.Replace("</A>", "")

                    Dim output As String = Regex.Replace(btn.Text, """>", "", RegexOptions.Multiline Or RegexOptions.Singleline)

                    Dim value As String = output
                    Dim index As Integer = value.IndexOf(str)

                    If index <> -1 Then
                        value = value.Remove(index) 'contains customer id
                    End If
                    
                    
                    btn.Text = str 'value & " " & str 'contains customer id & name 

                    btn.Tag = value

                    btn.TextAlign = ContentAlignment.MiddleLeft
                    btn.Dock = DockStyle.Top
                    btn.Refresh()
                    AddHandler btn.Click, AddressOf pluser1_LinkClicked
                    Panel1.Controls.Add(btn)
                End If
            Next
            i += 1

    End Sub

Thanks

Post Reply

Return to “Coding Help & Support”