-
VBA website scrapping help
Hi All,
I found the below sample code which works fine. I tried to mimic the code by using another website, but cannot even reach the input parameters.
The website has two text boxes.
Once you insert value to the first box, it will automatically return a result value to the second box ( no button to click)
here is where I tried to change:
First box ( input)
*tr id="send-num"*
*td class="rates-label-cell"*Send:*/td*
*td class="rates-input-cell"**input type="text" pattern="[0-9]*" placeholder="$0.00" class="amount"**/td*
*td class="rates-flag-cell dropdown"*
*button class="dropdown-toggle" data-toggle="dropdown"*
the second box ( return)
*tr id="receive-num"*
*td class="rates-label-cell"*Receive:*/td*
*td class="rates-input-cell"**input type="text" pattern="[0-9]*" placeholder="0.00 GHS" class="amount"**/td*
*td class="rates-flag-cell dropdown"*
*button class="dropdown-toggle" data-toggle="dropdown"*
Here is the sample code that is working with another website.
-------******************** Code begins here *************
Sub pullDataFromWeb()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://www.automationandagile.com/p/demo-page.html"
Do While IE.Busy Or IE.readyState ** 4
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
For intRow = 2 To 5
IE.document.getElementById("num1").Value = ThisWorkbook.Sheets("sheet1").Range("A" & intRow).Value
doc.getElementById("num2").Value = ThisWorkbook.Sheets("sheet1").Range("B" & intRow).Value
doc.getElementById("btnCalculate").Click
strAdd = doc.getElementById("lblAdd").innerText
strMult = doc.getElementsByClassName("clslbl")(2).innerText
ThisWorkbook.Sheets("Sheet1").Range("C" & intRow).Value = strAdd
ThisWorkbook.Sheets("Sheet1").Range("D" & intRow).Value = strMult
Application.Wait DateAdd("s", 2, Now)
Next
IE.Quit
MsgBox "Done"
End Sub
---****end code**************
Thanks in advance.
kevin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules