Jump to content

IE not loading postcode lookup website


Recommended Posts

Hi there, i'm having a little trouble loading/reading the HTML from this website

https://getaddress.io/

this is what the email they sent me with my API key says to do

For example: 'https://api.getAddress.io/find/sw1a2aa?api-key=ws4rBBEfakGBhnkWgsyy9Q15005'

 

when I use this script I wrote (which has had no problem in the past retrieving HTML from websites) it seems to freeze, am I doing something wrong? is it the wrong way to use it? I'm really lost sorry.

it also comes up with some strange message at the bottom of the IE window (supplied photo displays)

 

;TEST
#include <IE.au3>
$Postcode = "CM14 4SD" ; RANDOM FOR TESTING
$HTML = _READHTML("https://api.getaddress.io/find/"&stringreplace($postcode," ","")&"?api-key=ws4rBBEfakGBhnkWgsyy9Q15005", 8000, 1)

If Not @error Then
    $sFilePath = @DesktopDir & "\IE RESULTS " & @HOUR&@MIN&@SEC & ".txt"
    $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    FileWrite($hFileOpen, $html)
    FileClose($hFileOpen)
EndIf

Func _READHTML($WebsiteHTML, $_HTMLtimeout = 8000, $HTML_Visible = 0, $_HTMLTimerMAX = 8000)
    If $WebsiteHTML = "" then Return(SetError(1, 0, "No website provided"))
    $_HTMLTimer = TimerInit()
    If not ($WebsiteHTML = "") then
        Do
            $oIE = _IECreate($WebsiteHTML, 0, $HTML_Visible)
            $oIEResults = _IEBodyReadText ( $oIE )
        Until ($oIEResults <> "") or (TimerDiff($_HTMLTimer) >= $_HTMLTimerMAX) or @error
        _IEQuit($oIE)
        If $oIEResults = "" then Return(SetError(2, 0, "Timed out"))
        Return($oIEResults)
    EndIf
EndFunc

Screen Shot 2018-08-21 at 15.20.17.png

 

Also when I type into an IE explorer window that I open myself it gets all the results as expected, just not working when using a script

Edited by joboy2k
Link to comment
Share on other sites

Instead of using the _IE functions, I would use the WinHTTP UDF.

Here's an example --

#include <WinHttp.au3>

GetAddresses('sw1a2aa')

Func GetAddresses($sPostCode)
Local $sDomain = "api.getaddress.io"
Local $sPage = "find/"
Local  $sAdditionalData = '?api-key=ws4rBBEfakGBhnkWgsyy9Q15005'

Local $hOpen = _WinHttpOpen()
Local $hConnect = _WinHttpConnect($hOpen, $sDomain, $INTERNET_DEFAULT_HTTPS_PORT)
Local $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sPage & $sPostCode & $sAdditionalData)

_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

ConsoleWrite("+ Returned = " &  $sReturned & @CRLF)
EndFunc

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Both brilliant options and both work perfectly for what I need. Thank you so much.

Was I doing something specifically wrong? or was I just asking something that isn't possible for the method I was using?

 

Many thanks again

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...