GetUrl Library for windows

Developed or developing a new product in PureBasic? Tell the world about it.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

GetUrl Library for windows

Post by Num3 »

This new library is available on PureArea.net.
This set of commands is written in 100% PureBasic code, which means it will work under all OS versions of Purebasic that support version 3.90 or superior. For now only the windows version is released.

Linux version is only pending on 3.90 release.

OsX and Amiga will also support this library if they reach 3.90.

Consider this library Beta and unfinished, there is still much work to do :P
Commands:
GetUrlLastMod(*Struct.filedata)

Retrieves the last modified date of the especified file.

This command is usefull to check if there are any updates on a file


--------------------------------------------------------------------------------

GetUrlFile(*Struct.filedata)

Downloads the especified file. This does not work with php / jsp / perl on-the-fly generated pages, because usually the page file size is not returned :(


--------------------------------------------------------------------------------

GetUrlProgress()
Last edited by Num3 on Sun May 02, 2004 11:50 am, edited 2 times in total.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

8)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Thank you very much! Now i dont have to mess with thos OS-specific API codes! Waiting for the geturlsize function or so i can download a file with unknown file-size.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Looks good Num3! Will it download-to-buffer if no filename supplied?
Shopro
Enthusiast
Enthusiast
Posts: 148
Joined: Tue May 13, 2003 8:05 am

Post by Shopro »

Cool Num3:)

Lots of people would use this, probably including me:)

-Shopro
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Excellent!!

Can do more than one download at the same time?
ARGENTINA WORLD CHAMPION
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2139
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

@ricardo: Its already available on PureArea.net, so this shouldn't be a problem... :wink:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Andre wrote:@ricardo: Its already available on PureArea.net, so this shouldn't be a problem... :wink:
Thanks Andre!

I mean download more than one webpage with this libeary at the same time.
ARGENTINA WORLD CHAMPION
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Yes you can downladoad several files at once (every time you call the function a thread is created), the only side effect is that the progress call back will return wacky values (because of the several threads).

I intent to solve this later on too :P
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Thank you Num3 so much for this new library.

It's cool. :D
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

hi num3

i've realised a sort of frontend for your lib
this works a treat...
but as you said there's a lot of things to do

if you're agree, it would be good idea to add this features :

DownloadedBytes.l = GetUrlDownloadedSize()

Result.l = GetUrlCancelDownload()
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

sorry, i just seen in your doc (at the end) that
you are already working on those 2 commands

so good news
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

love the lib Num3.. kicks as$. ..

- np
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2139
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Num3, would you create an updated archive of the GetURL lib ?

According to the thread about the GetURL sourcecode I noticed, that you released the sourcecode in an updated version.

Would be really nice, to have an complete up-to-date userlib archive on PureArea.net again ! :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

see here: viewtopic.php?t=11095

i found severel bugs. The crypted of UserName+Pass is wrong. The error-code-check is wrong (it could happen, that a 404-file not found is detected, when in the tag-string is a "404"), not all errors are detected, use of threads -> unsecure.

And finaly:

With this code you can analyse the date from the server.

Code: Select all

Dim wkday$(6)
Dim weekday$(6)
Dim Month$(12)
wkday$(1)="MON" 
wkday$(2)="TUE" 
wkday$(3)="WED"
wkday$(4)="THU" 
wkday$(5)="FRI"
wkday$(6)="SAT"
wkday$(0)="SUN"
weekday$(1)="MONDAY"
weekday$(0)="TUESDAY"
weekday$(0)="WEDNESDAY"
weekday$(0)="THURSDAY"
weekday$(0)="FRIDAY"
weekday$(0)="SATURDAY"
weekday$(0)="SUNDAY"
Month$(1)="JAN"
Month$(2)="FEB"
Month$(3)="MAR"
Month$(4)="APR"
Month$(5)="MAY"
Month$(6)="JUN"
Month$(7)="JUL"
Month$(8)="AUG"
Month$(9)="SEP"
Month$(10)="OCT"
Month$(11)="NOV"
Month$(12)="DEC"
;            1    2  3    4     5 
;TestTime$="Sun, 06 Nov 1994 08:49:37 GMT"
;              1         2       3
;TestTime$="Sunday, 06-Nov-94 08:49:37 GMT"
;           1   2   3    4       5
TestTime$="Sun Nov  6 08:49:37 1994"


TestTime$=ReplaceString(Trim(UCase(TestTime$)),"  "," ")

Day=0:Month$="":Year=0:Time$=""
For i=0 To 6
  If Left(TestTime$,4)=wkday$(i)+","
    Debug "rfc1123-Date"
    ;{
    Day=Val(StringField(TestTime$,2," "))
    Month$=StringField(TestTime$,3," ")
    Year=Val(StringField(TestTime$,4," "))
    Time$=StringField(TestTime$,5," ") 
    ;}
  ElseIf Left(TestTime$,Len(weekday$(i))+1)=weekday$(i)+","
    Debug "rfc850-Date"
    ;{
    SubTime$=StringField(TestTime$,2," ")
    Day=Val(StringField(SubTime$,1,"-"))
    Month$=StringField(SubTime$,2,"-")
    Year=Val(StringField(SubTime$,3,"-"))
    If Year>80:Year+1900:Else:Year+2000:EndIf
    Time$=StringField(TestTime$,3," ")
    ;}
  ElseIf Left(TestTime$,4)=wkday$(i)+" "
    Debug "asctime-Date"
    ;{
    Day=Val(StringField(TestTime$,3," "))
    Month$=StringField(TestTime$,2," ")
    Year=Val(StringField(TestTime$,5," "))
    Time$=StringField(TestTime$,4," ") 
    ;}
  EndIf
Next
For i=1 To 12
  If Month$(i)=Month$ : Month=i : EndIf
Next
Date=ParseDate("%hh:%ii:%ss",Time$)
Hour=Hour(Date)
Min=Minute(Date)
Sec=Second(Date)
Date=Date(Year,Month,Day,Hour,Min,Sec)

Debug FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss",Date)
Post Reply