0

I want to extract values from a webpage, I have to make multiple inputs and clicks before I can get to the data I want so I don't want to scrape until after I've selected all the search parameters.

I need the values after object and navigate happens after changing the search/narrowing down. I created a module, loaded internet controls etc. that's all working, page loads. After loading I change the search params on the page and I get updated results and THEN I want to extract the values. Any help would be appreciated….

update code involved:

I was trying to use shdocvw.internetexplorer

Sub PULLDATA()

Dim IE As Object
Dim ieObj As InternetExplorer
Dim htmlEle As IHTMLElement
Dim i As Integer


Set IE = GetIE("'URL Hidden")

' initialize i to one
i = 2
For Each htmlEle In IE.document.getElementsByClassName("number")       (0).getElementsByTagName("li")
    With ActiveSheet
        .Range("B" & i).Value = htmlEle.Children(0).textContent
        .Range("C" & i).Value = htmlEle.Children(1).textContent
        .Range("D" & i).Value = htmlEle.Children(2).textContent
        .Range("E" & i).Value = htmlEle.Children(3).textContent
        .Range("F" & i).Value = htmlEle.Children(4).textContent
    End With

    i = i + 1

Next htmlEle

End Sub

    .Quit

End With

Set ie = Nothing

End Sub

I am just starting to build this but the bones are here

I just need clarification, surely someone has a base code to add elements to the worksheet instead of automating then retrieve the values... I'm sure to make it once I've checked the various filters on the page, which contains the classes and divs, and updated the page which I have to do MANUALLY and can populate the specific sheet in the workbook

CJtheLion
  • 34
  • 7
  • There are ways to attach to an already-loaded page. E.g. https://stackoverflow.com/questions/38859727/vba-choosing-specific-tab-on-internet-explorer/38860882#38860882 – Tim Williams Jun 15 '19 at 23:09
  • Please include your code, relevant html, description of expected return values. See [mcve] and [ask] for help. – QHarr Jun 16 '19 at 06:56
  • Tim, sure info is true but I don't want to just validate that it's the only window open or which tab, etc. Accessing the page is not enough, so validating and checking for tabs is all useless. this is for personal use and won't be deployed anywhere, with user worries etc. and is strictly run. I have a sheet that I will put the values in but opening a new and navigating and then entering multiple input entries expecting additional navigation is not necessary. – CJtheLion Jun 16 '19 at 13:57
  • Updated @QHarr also see answer to TIm. A clean base code would help me in the right direction. – CJtheLion Jun 16 '19 at 13:58
  • You can loop testing the document.url or title. There are SO questions covering this. – QHarr Jun 16 '19 at 14:04
  • Tim Williams might be the man...successfully accessed the ONLY open window from your code, awesome prints document title in immediate window, so far so good I want to incorporate the code above (fixed of course) it's a mess while I try different things – CJtheLion Jun 16 '19 at 14:41

0 Answers0