I tried to extract somes information from ALibaba.com but i didn't success to select Supplier in the list
Here is the html code
Set Post = IEdoc_ALi.getElementsByClassName("ui-searchbar-type-option").Item
Post.all(2).innerText = "Suppliers"
Thanks in advance
It's a link that needs clicking. You can use a css attribute = value selector to target the relevant node and then apply the click method.
Option Explicit
Public Sub SelectSuppliers()
Dim ie As SHDocVw.InternetExplorer
Set ie = New SHDocVw.InternetExplorer
With ie
.Visible = True
.Navigate2 "https://www.alibaba.com/"
While .Busy Or .readyState <> 4: DoEvents: Wend
.document.querySelector("[data-value=suppliers]").Click
Stop '<Delete me later
End With
End Sub
Related
I need to loop through a dropdown list of a specific website and download the latest file for each entry. I managed to open the website and click the "submit" button, but I can´t find a solution to loop through all the dropdown entries.
Dim reportnr As String
Dim internetadress As String
Dim btn As Object
Dim IE As SHDocVw.InternetExplorer
reportnr = 10
internetadress = adress & reportnr
Set IE = CreateObject('InternetExplorer.Application')
IE.Visible = True
IE.navigate internetadress
Do While IE.Busy
Application.Wait DateAdd("s", 2, Now)
Loop
While IE.Busy
DoEvents
Wend
For Each btn In IE.document.getElementsByClassName("btn btn-primary")
If btn.name = "submit" Then
btn.Click
End If
Next btn
The code on the website regarding the dropdown below.
I tried several approchoaches, but I´ll get error or just nothing happens. Last thing I tried is this :
Option Explicit
'VBE > Tools > References:
' Microsoft Internet Controls
Public Sub SelectQuantity()
Dim ie As New InternetExplorer, numberOfOptions As Long, i As Long
With ie
.Visible = True
.Navigate2 "https://www.amazon.com/belif-True-Cream-Aqua-Korean/dp/B00H4GOAZO/ref=pd_cart_crc_cko_cp_2_2/139-8277217-3794320?_encoding=UTF8&pd_rd_i=B00H4GOAZO&pd_rd_r=e154e278-8a11-4ab0-8173-5d0dbaff1938&pd_rd_w=Hm8FW&pd_rd_wg=Hpv4X&pf_rd_p=eff166ab-25d2-4f2c-a51d-0a0e86061f9d&pf_rd_r=EVT26E6K7CV8T1QMTY7H&psc=1&refRID=EVT26E6K7CV8T1QMTY7H"
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
numberOfOptions = .querySelectorAll("#quantity option").Length 'gather option tag element children of parent select element with id quantity
For i = 1 To numberOfOptions
.querySelector("#quantity [value='" & i & "']").Selected = True
ActiveSheet.Cells(i, 1) = i
Next
Stop
End With
End With
End Sub
Source: VBA loop through dropdown elements from web page and download to excel sheet
Thanks in advance for help.
From the website you provide, you can try the following code to loop through the dropdown list to choose the option you want:
Set lists = IE.document.getElementsByClassName("active-result") 'get all the options li elements
For Each liElement In lists
If liElement.innerText = "something" Then
liElement.setAttribute "class", "active-result result-selected"
End If
Next liElement
I find that the chosen option has different class which is active-result result-selected, so I think maybe you can change the class to select the option.
I've created a script in vba using IE to get the content poputaled upon selecting an option from dropdown. In the site's landing page there is a dropdown named Type. When I click on Type, I can see few options there and I would like to click on corporate bond among them. When the result are generated I would like to parse the WKN.
I've tried to populate results using my current script by clicking on the dropdown and selecting an option from there. However, it clicks on the dropdown and select the desired option but can't produce any result in InternetExplorer.
How can I populate and parse the result selecting an option from dropdown?
My attempt so far:
Sub SelectItem()
Const link = "https://www.boerse-stuttgart.de/en/tools/product-search/bonds/"
Dim IE As New InternetExplorer, Html As HTMLDocument, post As Object, T As Date
With IE
.Visible = True
.navigate link
While .Busy Or .readyState < 4: DoEvents: Wend
Set Html = .document
End With
Application.Wait Now + TimeValue("00:00:15")
Html.querySelector("#bsg-filters-btn-bgs-filter-3 .bsg-btn__icon").Click
Application.Wait Now + TimeValue("00:00:05")
Html.querySelector("#bsg-filters-menu-bgs-filter-3 .bsg-scrollbox label[for='bsg-checkbox-3053']").Click
Application.Wait Now + TimeValue("00:00:05")
Html.querySelector(".bsg-dropdown__footer button[type='button']").Click
End Sub
You are familiar with timed loops so you can add timeouts to the following. I use css selectors through out to target elements. I monitor for the disappearance of the whirring circles as measures of page load at various points. At the end I monitor for presence of results items nodeList nodes.
Option Explicit
'VBE > Tools > References:
' Microsoft Internet Controls
Public Sub GetCodes()
Dim ie As New InternetExplorer, btn As Object, items As Object, i As Long
With ie
.Visible = True
.Navigate2 "https://www.boerse-stuttgart.de/en/tools/product-search/bonds"
While .Busy Or .readyState < 4: DoEvents: Wend
Do
Loop Until .document.querySelectorAll(".bsg-loader-ring__item").Length = 0
.document.querySelector("#bsg-filters-btn-bgs-filter-3").Click
.document.querySelector("#bsg-checkbox-3053").Click
Set btn = .document.querySelector("#bsg-filters-menu-bgs-filter-3 .bsg-btn__label")
Do
Loop While btn.innerText = "Close"
btn.Click
Do
Loop Until .document.querySelectorAll(".bsg-loader-ring__item").Length = 0
Dim count As Long
Do
On Error Resume Next
Set items = .document.querySelectorAll(".bsg-table__tr td:first-child")
count = items.Length
On Error GoTo 0
Loop While count = 0
For i = 0 To items.Length - 1
Debug.Print items.item(i).innerText
Next
.Quit
End With
End Sub
I am working on a web form fill using excel cells data, and the issue here is that after filling the text in the first page using the elements ID, when it click on Submit it loads a new IE.
Now here I am not able to fill the text using the elements ID etc, as its (VBA) not identifying it or not considering it.
IE Page loads properly here no issue.
Sub Test1()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://xyzfrmTarget=New&Text_ident=002719&frmOption=CREATE"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
'IE.document.getElementById().Value="test"
'doc.getElementById("ui-new_widget-1_new_company_12").Value = ThisWorkbook.Sheets("Data").Range("A2").Value
doc.getElementById("ui-new_widget-1_monitor_12").Value = ThisWorkbook.Sheets("Data").Range("A2").Value
doc.getElementById("new_date").Value = "2019-01-19"
'ThisWorkbook.Sheets("Data").Range("c2").Value
doc.getElementById("new_no_mail").Click
IE.document.forms(0).submit
End Sub
It submit the 1st page with the Text data from excel, but issue with the 2nd page which loads
Try using proper waits after navigate and .click and work off .document. This should update with new content after the .click
Option Explicit
Public Sub PerformActions()
Dim IE As InternetExplorer
Set IE = New InternetExplorer
With IE
.Visible = True
.Navigate2 "https://xyzfrmTarget=New&Text_ident=002719&frmOption=CREATE"
While .Busy Or .readyState < 4: DoEvents: Wend
.document.getElementById("ui-new_widget-1_monitor_12").Value = ThisWorkbook.Sheets("Data").Range("A2").Value
.document.getElementById("new_date").Value = "2019-01-19"
.document.getElementById("new_no_mail").Click
While .Busy Or .readyState < 4: DoEvents: Wend
'.document ''< do whatever references off .document here
'other code
'.quit
End With
End Sub
I have this simple macro that opens up IE and type a word in search box. It was working before, but now is returning
Error 424 - Object required.
Any ideas on what is happening? Is there any lib reference that I'm missing?
Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("https://www.google.com/")
Do While ie.Busy Or ie.readyState <> 4
DoEvents
Loop
Set xobj = ie.document.getElementById("lst-ib")
Call xobj.setAttribute("value", "teste")
End Sub
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search. Use whatever your local value is.
Element html:
Other:
Also, .navigate2 is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
I have some code that used to work fine, but for some reason it has stopped selecting the tab that says "your leagues".
The code pulls live football scores into excel.
The only bit I need help with is where I need to navigate from all games to your leagues (the code does not recognize the button and so is not clicking it). Any help will be appreciated. Thanks.
'Define Variables
url = "http://www.futbol24.com/Live/livenow/"
'Open url
ie.Visible = False
ie.Navigate url
frmbusy.lbstatus.AddItem "Navigating to Web Page"
busywait
'Navigate from ALL Games to Your Leagues
Set tagname = ie.Document.getelementsbytagname("*")
For z = 0 To tagname.Length - 1
If tagname(z).ID = "f24com_i18n_btnChooseLeague_your" Then
tagname(z).Click
busywait
End If
Next
You can use a querySelector to target
#f24com_btnChooseLeague_choose > a > span
This is the span tag within an a tag with element with id #f24com_btnChooseLeague_choose
You can shorten this simply to #f24com_btnChooseLeague_choose > a
Option Explicit
Public Sub ClickChooseLeagues()
Dim ie As New InternetExplorer
With ie
.Visible = True
.navigate "https://www.futbol24.com/Live/livenow/"
While .Busy Or .readyState < 4: DoEvents: Wend
.document.querySelector("#f24com_btnChooseLeague_choose > a").Click
Stop
End With
End Sub