Page 1 of 1

Problem Reading Webpage

Posted: Wed Apr 25, 2012 2:52 pm
by akj
This webpage https://www.transit-transit.com/pagina/hub.htm is quite lengthy (10858 bytes) but when read with PureBasic's ReceiveHTTPFile() command the result is only 230 bytes.
The HTML read by ReceiveHTTPFile() appears to be a request to redirect (error 302), but to identically the same webpage.
So how can I properly read the HTML in this webpage?
The code I am using is:

Code: Select all

; Problem Reading Webpage
#file = 0
Define url$ = "https://www.transit-transit.com/pagina/hub.htm"
Define file$ = "C:\html.txt"
Define header$, html$, p
InitNetwork()
; Get HTTP header
header$ = GetHTTPHeader(url$)
Debug "Header = " + ReplaceString(header$, Chr(10), "¬")
Debug ""
; Get HTML code
ReceiveHTTPFile(url$, file$)
Debug "Filesize = "+Str(FileSize(file$))+" bytes" ; Web page size is 10858 bytes
Debug ""
ReadFile(#file, file$)
While Not Eof(#file)
  Debug ReadString(#file)
Wend
End

Re: Problem Reading Webpage

Posted: Wed Apr 25, 2012 4:10 pm
by UrgentKettle
I do not think that the native PB HTTP functions will cope with HTTPS.

Try using libCurl.

Re: Problem Reading Webpage

Posted: Wed Apr 25, 2012 6:04 pm
by akj
I have managed to solve the problem by replacing

Code: Select all

ReceiveHTTPFile(url$, file$)
by

Code: Select all

URLDownloadToFile_(0,url$,file$,0,0)

Re: Problem Reading Webpage

Posted: Wed Apr 25, 2012 11:09 pm
by USCode
I wonder which Win API command Fred is using for the PB command ReceiveHTTPFile() ?