Page 1 of 1
Simple way to get a web page?
Posted: Mon Apr 28, 2008 9:33 am
by codefire
Does anyone know a simple way to download a webpage over the Net in PureBasic?
I'm looking for something like:
Code: Select all
GetWebPage(file, "http://www.somesite.com/page.html")
Basically I just want to get a page - I can do the processing after that.
Many thanks,
Tony
Posted: Mon Apr 28, 2008 10:03 am
by ts-soft
This is in PB 4.20 beta only
Posted: Mon Apr 28, 2008 10:08 am
by codefire
That's exactly what I need
Many thanks - I'll upgrade from 4.10 to 4.20 Beta later today.
Posted: Mon Apr 28, 2008 11:01 am
by Shardik
It is not necessary to update to 4.20 Beta for ease of use, because for Windows operating systems the task of downloading the html code of a web page is also only one function call:
URLDownloadToFile_(0, @URL, @DownloadFilename, 0, 0)
A small example:
Code: Select all
URL.S = "http://www.google.com"
DownloadFilename.S = GetTemporaryDirectory() + "Test.htm"
If URLDownloadToFile_(0, @URL, @DownloadFilename, 0, 0) = #S_OK
MessageRequester("Info", URL + " has been downloaded sucessfully into " + DownloadFilename + "!", #MB_ICONINFORMATION)
Else
MessageRequester("Error", "The download of " + URL + " failed!", #MB_ICONERROR)
EndIf
Posted: Mon Apr 28, 2008 11:40 am
by ts-soft
@Shardik
Some AntiVirus programs have problems with URLDownloadToFile_ API
and there some problems with cache and so on. IMHO not the best way.
Posted: Mon Apr 28, 2008 12:43 pm
by Shardik
ts-soft wrote:Some AntiVirus programs have problems with URLDownloadToFile_ API
That's unfortunately correct. But have you tested the new ReceiveHTTPFile() function in Exe files of PB 4.20 Beta with AntiVirus programs extensively? May be that they complain too about some function calls?
ts-soft wrote:and there some problems with cache and so on
Do you have some links for me because this would be very important for me and my customers. Fortunately I didn't have had any complaints so far for several programs in production using URLDownloadToFile().
ts-soft wrote:IMHO not the best way.
IMHO not the best way to use a new function of a Beta version in important programs.

Have you taken a look into the bug section? OK, meanwhile Fred has already fixed some of the reported bugs but can you guarantee that there are not other bugs still not found or reported?

I think that many programmers are still waiting for the final version and that some bugs still will be detected after most PureBASIC users have upgraded to the new PB 4.20 final...
Posted: Mon Apr 28, 2008 1:17 pm
by ts-soft
Shardik wrote:Do you have some links for me because this would be very important for me and my customers. Fortunately I didn't have had any complaints so far for several programs in production using URLDownloadToFile().
The second downloads, only download from the cache, if available, so you
have to clear the cache. For websites is this no problem, but for files
downloaded in this way.
Posted: Mon Apr 28, 2008 3:30 pm
by Shardik
@ts-soft,
thank you for bringing into attention the problem with possibly having to clear the cache, although this is quite straightforward:
Simply place DeleteUrlCacheEntry_(URL) before calling URLDownloadToFile(). Examples have already been posted by PB (
http://www.purebasic.fr/english/viewtop ... 12&start=1) and Kiffi and teachco (
http://www.purebasic.fr/german/viewtopic.php?t=12314).