Hi oryaaaaa,
You can implement this your self using the tools that are at your disposal. Since this method uses nothing but the built in functions it should be cross platform.
Code: Select all
InitNetwork()
CreateRegularExpression(0, "(302|301)")
CreateRegularExpression(1, "http://.*$")
CreateRegularExpression(2, "http://.*/")
CreateRegularExpression(3, "200")
inputurl$ = ProgramParameter(0)
Procedure.s Parse302(url$)
Header$ = GetHTTPHeader(url$)
Index = 0
Index+1
Line$ = StringField(Header$, Index, #LF$)
If MatchRegularExpression(0, Line$)
Debug "302 FOUND!... Parsing."
Repeat
Index+1
Line$ = StringField(Header$, Index, #LF$)
Until MatchRegularExpression(1, Line$)
Dim Result$(0)
ExtractRegularExpression(1, Line$, Result$())
Debug Result$(0)
Else
Debug url$
ProcedureReturn url$
EndIf
ProcedureReturn Result$(0)
EndProcedure
Repeat
inputurl$ = Parse302(inputurl$)
Header$ = GetHTTPHeader(inputurl$)
Index = 0
Index+1
Line$ = StringField(Header$, Index, #LF$)
Until MatchRegularExpression(3, Line$)
Debug "Attempting to download file."
Dim Result$(0)
filename$ = GetCurrentDirectory() + ReplaceRegularExpression(2, inputurl$, "")
filename$ = Left(filename$, Len(filename$)-1)
Debug filename$
PrintN("Downloading file: " + filename$)
ReceiveHTTPFile(inputurl$, filename$)
PrintN("Done!")
This is a rough idea of what could be done that I threw together. Basically you could inspect the headers of the URL you are wanting to process and determine if it's a redirect "302" or "301" then just parse out the information as needed.
This code when compiled takes one param via the commanline, the url. Best to encapsulate the url with quotes as some of the characters in URLs don't make bash very happy.
Anyway sorry for the rough code I have been away from PB for a while and I'm starting to pick it back up.
Hope it helps.
Boop64