Problem Reading Webpage

Just starting out? Need help? Post your questions and find answers here.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Problem Reading Webpage

Post 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
Anthony Jordan
UrgentKettle
User
User
Posts: 12
Joined: Thu Jan 27, 2011 12:25 pm

Re: Problem Reading Webpage

Post by UrgentKettle »

I do not think that the native PB HTTP functions will cope with HTTPS.

Try using libCurl.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Re: Problem Reading Webpage

Post 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)
Anthony Jordan
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: Problem Reading Webpage

Post by USCode »

I wonder which Win API command Fred is using for the PB command ReceiveHTTPFile() ?
Post Reply