vb.net automate some work
vb.net automate some work
vb.net automate some work
vb.net automate some work
vb.net automate some work
vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work
vb.net automate some work vb.net automate some work
vb.net automate some work
Go Back  Xtreme Visual Basic Talk > > > vb.net automate some work


Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2014, 09:03 AM
predricted predricted is offline
Newcomer
 
Join Date: Jul 2013
Posts: 14
Default vb.net automate some work


Hello all,

I try to make a software to spare some time with publishing advertisments.
Now i'm busy to automatically press categories and then fill some information.
The code below is working a little bit.
Its going through the categories and then at the next page it does not fill the information.
Like title, description.
However if i change wait(100) with MsgBox() it does fill in the information but i get tons of message boxes.

Can somebody help me out..
Thank you!


Code:
    Private Sub button_add_publiceer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_add_publiceer.Click
        webbrowser_global.ScriptErrorsSuppressed = True
        webbrowser_global.Navigate("https://www.marktplaats.nl/syi/plaatsAdvertentie.html")
        PublishStatus = 2
    End Sub
    Private Sub webbrowser_global_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles webbrowser_global.DocumentCompleted
        ' you'll want to put some sort of test for the appropriate page in here
        ' no point running the timer when it's not needed
        If webbrowser_global.Url = New Uri("https://www.marktplaats.nl/syi/plaatsAdvertentie.html") And PublishStatus = 2 Then
            SelectionTimer.Start()
        End If
    End Sub
    Private Sub SelectionTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionTimer.Tick
        ' no point in running through every tag on the page so limit to <li>
        Dim clickdone As String = "0"
        Dim nextpage As String = "No"
        For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("div")
            If el.GetAttribute("id") = "syi-categories-l1" And clickdone = "0" Then  ' find the ul
                For Each elchild As HtmlElement In el.GetElementsByTagName("ul")
                    If elchild.GetAttribute("classname") = "listbox item-frame" And clickdone = "0" Then
                        For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("li")
                            If elchild2.GetAttribute("data-val") = combobox_add_categorienr.Text And clickdone = "0" Then ' category
                                elchild2.InvokeMember("Click")
                                clickdone = "1"
                            End If
                        Next
                    End If
                Next
            End If
            If el.GetAttribute("id") = "syi-categories-bucket" And clickdone = "1" Then  ' find the ul
                For Each elchild As HtmlElement In el.GetElementsByTagName("ul")
                    If elchild.GetAttribute("classname") = "listbox item-frame" Then
                        For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("li")
                            If elchild2.GetAttribute("data-val") = combobox_add_subcategorienr.Text Then ' category
                                elchild2.InvokeMember("Click")
                                clickdone = "2"
                            End If
                        Next
                    End If
                Next
            End If
            If el.GetAttribute("id") = "syi-categories-l2" And clickdone = "2" Then  ' find the ul
                For Each elchild As HtmlElement In el.GetElementsByTagName("ul")
                    If elchild.GetAttribute("classname") = "listbox item-frame" Then
                        For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("li")
                            If elchild2.GetAttribute("data-val") = combobox_add_subcategorie2nr.Text Then ' category
                                elchild2.InvokeMember("Click")
                                clickdone = "3"
                            End If
                        Next
                    End If
                Next
            End If
        Next

        If webbrowser_global.ReadyState = 4 Then
            Dim prijstypeid As String = ""
            If combobox_add_prijstype.Text = "Vaste prijs" Then
                prijstypeid = "fixed-price"
            Else
                If combobox_add_prijstype.Text = "Vrij bieden toestaan" Then
                    prijstypeid = "free-bidding"
                Else
                    If combobox_add_prijstype.Text = "Bieden vanaf vraagprijs" Then
                        prijstypeid = "bid-higher"
                    End If
                End If
            End If

            If webbrowser_global.ReadyState = 4 Then
                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("input")
                    If el.GetAttribute("name") = "title" Then  ' find the ul
                        webbrowser_global.Document.GetElementById("title").SetAttribute("value", textbox_add_titel.Text)
                    End If
                Next
                SetTinyContent(webbrowser_global, textbox_add_omschrijving.Text)
                webbrowser_global.Document.InvokeScript("tinyMCE.activeEditor.setContent('');")
                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("input")
                    If el.GetAttribute("name") = "price.value" Then  ' find the ul
                        webbrowser_global.Document.GetElementById("price.value").SetAttribute("value", textbox_add_prijs.Text)
                    End If
                Next

                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("div")
                    If el.GetAttribute("classname") = "form-field" Then  ' find the ul
                        For Each elchild As HtmlElement In el.GetElementsByTagName("span")
                            If elchild.GetAttribute("id") = "syi-attribute-321" Then
                                For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("ul")
                                    For Each elchild3 As HtmlElement In elchild2.GetElementsByTagName("li")
                                        If elchild3.InnerText = combobox_add_conditie.Text Then
                                            elchild3.InvokeMember("Click")
                                        End If
                                    Next
                                Next
                            End If
                        Next
                    End If
                Next
                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("div")
                    If el.GetAttribute("id") = "syi-price" Then  ' find the ul
                        For Each elchild As HtmlElement In el.GetElementsByTagName("p")
                            If elchild.GetAttribute("classname") = "form-field syi-bidding-radio-buttons" Then
                                For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("span")
                                    For Each elchild3 As HtmlElement In elchild2.GetElementsByTagName("input")
                                        If elchild3.GetAttribute("id") = prijstypeid Then
                                            elchild3.InvokeMember("Click")
                                        End If
                                    Next
                                Next
                            End If
                        Next
                    End If
                Next
                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("div")
                    If el.GetAttribute("classname") = "form-field" Then  ' find the ul
                        For Each elchild As HtmlElement In el.GetElementsByTagName("span")
                            If elchild.GetAttribute("id") = "delivery-options" Then
                                For Each elchild2 As HtmlElement In elchild.GetElementsByTagName("ul")
                                    For Each elchild3 As HtmlElement In elchild2.GetElementsByTagName("li")
                                        If elchild3.InnerText = combobox_add_leveringsvoorkeur.Text Then
                                            elchild3.InvokeMember("Click")
                                        End If
                                    Next
                                Next
                            End If
                        Next
                    End If
                Next
                For Each el As HtmlElement In webbrowser_global.Document.GetElementsByTagName("div")
                    If el.GetAttribute("id") = "uploader-container-0" Then
                        el.InvokeMember("Click")
                    End If
                Next
            End If
            wait(100)
            PublishStatus = 0
            SelectionTimer.Stop()
        End If
    End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
vb.net automate some work
vb.net automate some work
vb.net automate some work vb.net automate some work
vb.net automate some work
vb.net automate some work
vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work vb.net automate some work
vb.net automate some work
vb.net automate some work
 
vb.net automate some work
vb.net automate some work
 
-->