View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Pick data from web page (no query)

There are a few methods of getting the next page of a webpage. You can
activate the NEXT button, you can active the sheet number on the webpage, you
can enter a new URL with the page number as part of the URL. I think you are
refereing to the last method. Here is some code that I used on a different
project

I put "page=1&" at the end of the request.

The only problem is determining how many pages there are for the Webpage. I
checked the TAG "B" and looked at the property nextsibling to find out if
there was more pages.

URL = "http://www.config.nissanusa.com/Dispatch.jsp"
Request = "?changeModel=execute&" & _
"currentBodyType=" & Bodytype(body) & "&" & _
"_scrollPos=158&" & _
"locateConfig=true&" & _
"__action4=&" & _

"state_token=2%3A17%3Anissan%7Calt%7CALL%7C0%7CA4A AAAAAAAAA%7C%3A&" & _
".CurrentState=DealerMatchingVehiclesBrowse&" & _
"unselectVehicle=null&" & _
"tool=null&" & _
"sdealerID=" & dealerNumber & "&" & _
"sdealerContactable=true&" & _
"error_noResults=&"

Page = 0
Do
PageRequest = Request & "page=" & Page & "&"

IE.Navigate2 URL & PageRequest
Do While IE.readyState < 4
DoEvents
Loop

Do While IE.busy = True
DoEvents
Loop


Call GetCarDetails(IE, DealerName, City, Distance, BodyStyle)

If IE.document.getelementsbytagname("B").Length < 0 Then
Set PageNumbers = _
IE.document.getelementsbytagname("B") _
.Item(0).nextsibling

If Not PageNumbers Is Nothing Then
Page = Val(PageNumbers.innertext) - 1
End If
Else
Set PageNumbers = Nothing
End If
Loop While Not PageNumbers Is Nothing


"rik" wrote:

I get the same results
Can you explain me what this means for the page i try to work with ?


"Joel" wrote:

Check the ative sheet in the workbook starting at row 1. Here is what I got.
I discovered some of these items are hidden and can't be seen in the source.

objInloggenScreen
frmInloggen
__EVENTTARGET
__EVENTARGUMENT
__LASTFOCUS
__VIEWSTATE
txtJava
lnkLogo
lblWelkom
lblInloggen
lblTaal
DdlLanguage
lblRekNrOfAdviseur
txtLogin
valTxtLogin
txtPassword
btnLogIn
lnkbtnWachtwoordVergeten
__EVENTVALIDATION
oCapsLockWarn

You can get the value of one of these items with

Set last = IE.document.getElementByID("txtLogin")
Data = last.value


"rik" wrote:

Thanks for your answer but running your code does not bring anything in the
excel sheet ...
It runs without any failure code but it seems it cannot find any ID's ???

In the web page source though, i found all codes (as shown before) in the
pasted part of the code.
Do you have a solution ?

"Joel" wrote:

You are return nothing because it didn' tfind an ID= matching your criteria.
Try one of my two instruction and you will see it will return a value

Set last = IE.document.getelementsbytagname("Form")

'or
Set last = IE.document.getElementByID("objInloggenScreen")


Try this code which will get all the ID's. Then in the Internet Explorer
view the Source code from the menu VIEW - SOURCE. You'll see the items in
column A on the spreadsheet will match the ID= in the source

Sub Getquotes2()
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.ID
RowCount = RowCount + 1
End With
End If
Next itm

End Sub



"rik" wrote:

I'm sorry, but i'm not with you anymore :

"objInloggenScreen" ? Does this mean : the ID that i found in the source of
the web page (1068754|LAST, see pasted source in my first post)

add a Watch : i think i could do this although i couldn't find the plus (+)
you mentioned. Running with break point and watch gives me :

Watch : : last : Nothing : Variant/Object : Module1.Getquotes
so value = nothing
on website it is = 350,30

I also do not understand your sentence "When referencing these objects you
will use Last.innertext"

Basically, what i want to do is putting this value (350,30) into cell A1.
What do i do wrong ?