Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not Getting New Page HTML

Status
Not open for further replies.

nick---d

Technical User
May 30, 2017
1
GB
Hi,

using Excel VBA I am entering information onto a web page, submitting the data but cannot read the results page, the Internet Explorer's document is still holding the original page's html.
I have tried putting 5 second waits, 10 second waits even 1 minute waits after the ready state is OK after the form submit but to no avail.
The results URL contains no info so I cannot navigate there, and I cannot use a POST with the data variables from the input form because a unique reference is required each time ( as part of the POST data).
All required project references have been made

Could somebody point me in the right direction please?
Code:
Sub ParseInternet()
Dim i As Integer
Dim post_code As String
Dim house_num As String
post_code = CStr(Sheet1.Cells(9, 2).Value)
house_num = CStr(Sheet1.Cells(9, 1).Value)
If post_code = "" Then
    MsgBox ("House Name /Number and postcode MUST be entered")
    Exit Sub
End If

Set Site = CreateObject("InternetExplorer.application")

Dim URL As String


URL = "[URL unfurl="true"]http://landregistry.data.gov.uk/app/ppd"[/URL]

Site.Navigate URL
While Site.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
Application.Wait (Now + TimeValue("0:00:10"))
Site.Visible = True
Site.Document.getElementById("paon").Value = house_num
Site.Document.getElementById("postcode").Value = post_code
Site.Document.forms(0).submit


While Site.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
 Application.Wait (Now + TimeValue("0:00:10"))
'''''PREVIOUS PAGE'S HTML STILL IN SITE.DOCUMENT
Set HTMLTD = Site.Document.getElementsByTagName("TD")
For xTD = 0 To HTMLTD.Length - 1

j = Len(Site.Document.getElementsByTagName("TD")(xTD).innerText)

    If j > 0 And j < 20 Then
 
        Sheet1.Cells(9, xTD + 1).Value = Site.Document.getElementsByTagName("TD")(xTD).innerText
        Exit Sub
    End If

Next xTD

End Sub
 
Instead of:
[VBA]
...
[\VBA]

use:[ignore]
Code:
...
[/ignore]
to format your code.

You don't have to re-post, you can just edit your own post.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top