View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Rik Rik is offline
external usenet poster
 
Posts: 16
Default Pick data from web page (no query)

It's not reason nr. 2 : i changed the code a little bit (see below) and got
as a result :
nothing in colums AE
cell F1 = 1
cell G1 = 1, G2=2 etc untill G9=9

Setting a break point didn't change anything.

So probably it's reason nr. 1
Guess there's nothing to do about it ?

===========================================
Sub DumpData()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "https://www.binck.com/gekko/default.aspx?" & _
"Redir=/gekko/common/researchennieuws/fondsdetails/overzicht.aspx?binc=1068754"

'get web page
IE.Navigate2 URL
Do While IE.readyState < 4
DoEvents
Loop

Set last = IE.document.all
RowCount = 1
For Each itm In IE.document.all
If itm.ID < "" Then
With ActiveSheet
.Range("A" & RowCount) = itm.classname
.Range("B" & RowCount) = itm.tagname
.Range("C" & RowCount) = itm.onclick
.Range("D" & RowCount) = itm.ID
.Range("E" & RowCount) = Left(itm.innertext, 1024)
RowCount = RowCount + 1
End With
Else
Range("G" & RowCount) = RowCount
RowCount = RowCount + 1
End If
Next itm
Range("F1") = 1
End Sub

=====================================



"Joel" wrote:

there are two possible reasons that I can immediately think of that may be
causing the problem.

1) That the items are not in the IE.Document. It is something else beside a
document.
2) The code isn't waiting for the webpage to get the data before it reads
the data.

I usually set break points a first get the code working by stepping through
the instructions. I can wait until the webpage is updated before continue to
step through the code. Then I go back and try to get it to work
automatically. Here is a sample of code where I couldn't get the IE READY to
wrok. I had to use a return value from the page to force the code to wait.


'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click

On Error Resume Next ' Defer error handling.
Do
Err.Clear
Set PageNumber = IE.document.getElementById("pageNumber")
Pages = PageNumber.Value
DoEvents
Loop While Err.Number < 0
On Error GoTo 0


"rik" wrote:

I'm sorry to say but i tried "dumpdata" with 3 web pages :

1. the page to log in (which you can see as well) : it works perfectly well
2. the home page you get on once you're logged in : it runs without failure
but nothing is dumped into the excel sheet : he finds 9 empty items
3. the page i wanted to work with : same as 2 : also 9 empty items, so it
seems to be the same page, although a different page is seen on the screen

There must be something tricky that i don't understand ???
Does it make sense to try to go to the wanted page by filling in name and
password, and then click 2 buttons automatically ?