Hi All
I get similar errors but concerning STDOUT. If I comment STDOUT out line by line the error moves down
line by line. The first error is hit on the STDOUT "Webget v1.2 - Grab a file from a web site" line
Any ideas as to what is wrong, I copied and pasted the prog in from the original message.
Cheers Pete
Chad, I tried to compile on XP Home and Win2K, and both times got error 516:
Error 516 in C:\PBCC30\Samples\WebGet.bas(32:70): DefType, Type id (?%&!#$), or AS... required: HTTP
Line 32: STDOUT " Ex: webget <A HREF="http://www.powerbasic.com/index.html"" TARGET=_blank>http://www.powerbasic.com/index.html"</A>
I haven't had time to look into it yet, just an FYI. Thanks for sharing.
[/QUOTE]
------------------
X
-
Chad,
You'll want to update the following line
Code:TCP PRINT #1, "UserAgent: webget 1.3 (www.powerbasic.com)"
Code:TCP PRINT #1, "User-Agent: webget 1.3 (www.powerbasic.com)"
Cheers,
Scott
------------------
Scott Wolfington
http://www.boogietools.com
Leave a comment:
-
re-posted in the "programming the internet" forum. http://www.powerbasic.com/support/pb...ad.php?t=29523
scott
[this message has been edited by scott wolfington (edited july 08, 2004).]
Leave a comment:
-
Hey Chad/Everyone,
When I try this code, it sits and waits until the TCP timeout is hit and then it returns the web page. If I uncomment the EOF check within the loop, then it comes back much faster but I seem to be only getting the headers returned. I'm testing against a WebLogic web server and an IIS Web Server. When I don't do the EOF check within the loop, requesting a page from an IIS web server, it just hangs and doesn't seem to ever come back (CORRECTION: It finally came back when I was done writing this message). Any ideas?
Does the PowerBASIC team have any suggestions?
Scott
------------------
Scott Wolfington
http://www.boogietools.com
[This message has been edited by Scott Wolfington (edited July 07, 2004).]
Leave a comment:
-
Doh! Just realized I left the URL start/end blocks in when I copied the
code. Took them out and it works fine!
------------------
Mark Pruitt
[email protected]
Leave a comment:
-
Chad, I tried to compile on XP Home and Win2K, and both times got error 516:
Error 516 in C:\PBCC30\Samples\WebGet.bas(32:70): DefType, Type id (?%&!#$), or AS... required: HTTP
Line 32: STDOUT " Ex: webget <A HREF="http://www.powerbasic.com/index.html"" TARGET=_blank>http://www.powerbasic.com/index.html"</A>
I haven't had time to look into it yet, just an FYI. Thanks for sharing.
------------------
Mark Pruitt
[email protected]
Leave a comment:
-
Code:'Only works here with Windows 98 SE by changing: 'TCP PRINT #1, "GET " & file & " HTTP/1.1" 'to 'TCP PRINT #1, "GET " & file & " HTTP/1.0"
------------------
Leave a comment:
-
It only worked after I uncommented
If Eof(1) Then StdOut "": Exit Do
Without that, it just sat there.
Useful though, thanks!
Dave
------------------
Leave a comment:
-
Working WEBGET/WGET...
Code:' 'NOTE: Why a repost? Because I wasted thirty minutes until I noticed that 'the TIMEOUT setting of the TCP connection was overriding the 60 second default 'with 30 milliseconds, which was obviously far too short for even most fiber- 'optic network scenarios. ALSO I added ERR checking. ' '============================================================================== ' ' WEBGET v1.3 - Grab a file from a web site ' Copyright (c) 1999-2001 PowerBASIC, Inc. All Rights Reserved. ' '============================================================================== %port = 80 FUNCTION PBMAIN() AS LONG LOCAL buffer AS STRING LOCAL site AS STRING LOCAL file AS STRING LOCAL save AS STRING LOCAL temp AS STRING STDOUT "Webget v1.2 - Grab a file from a web site" STDOUT "Copyright (c) 1999-2001 PowerBASIC, Inc. All Rights Reserved." STDOUT "" IF LEN(COMMAND$) = 0 OR COMMAND$ = "/?" THEN STDOUT "Usage: webget url/file" STDOUT "" STDOUT " Ex: webget <A HREF="http://www.powerbasic.com/index.html"" TARGET=_blank>http://www.powerbasic.com/index.html"</A> EXIT FUNCTION END IF site = EXTRACT$(LTRIM$(LCASE$(COMMAND$),"http://"), "/") IF LEN(site) = 0 THEN STDOUT "Error! You must specify a web site." EXIT FUNCTION END IF file = TRIM$(MID$(COMMAND$, INSTR(LCASE$(COMMAND$), site) + LEN(site))) IF LEN(file) = 0 THEN STDOUT "Error! You must specify a file" EXIT FUNCTION END IF save = MID$(file, INSTR(-1, file, "/") + 1) IF LEN(save) = 0 THEN save = EXTRACT$(LTRIM$(site, "www."), ".") + ".html" END IF STDOUT "Connecting to " & site & " ..."; TCP OPEN PORT %port AT site AS #1 TIMEOUT 300000 IF ERR OR ERRAPI THEN STDOUT "" STDOUT "Could not connect to " & site STDOUT "ERR:" & TRIM$(STR$(ERR)) & " ERRAPI:" & TRIM$(STR$(ERRAPI)) EXIT FUNCTION ELSE STDOUT " OK!" STDOUT "" END IF STDOUT "Retrieving " & site & file & " to " & save & " "; TCP PRINT #1, "GET " & file & " HTTP/1.1" TCP PRINT #1, "Accept: */*" TCP PRINT #1, "Accept-Language: en-us" TCP PRINT #1, "Host: " & site TCP PRINT #1, "Pragma: no-cache" TCP PRINT #1, "Referer: <A HREF="http://www.google.com"" TARGET=_blank>http://www.google.com"</A> TCP PRINT #1, "UserAgent: webget 1.3 (www.powerbasic.com)" TCP PRINT #1, "" DO TCP RECV #1, 4096, buffer temp = temp & buffer STDOUT "."; ' 'Don't check EOF() in here because brief pauses in file download 'will leave an empty buffer and set EOF() until you next check 'and the buffer is full - at which point EOF() will be unset... ' 'From TCP RECV PB Help: If count& bytes are not available, Buffer$ 'will receive whatever bytes are available and EOF(fNum&) will 'return TRUE (non-zero). ' 'IF EOF(1) THEN STDOUT "": EXIT DO ' IF LEN(buffer) = 0 THEN STDOUT "": EXIT DO IF ERR THEN STDOUT "": EXIT DO LOOP IF ERR THEN STDOUT "ERR Error... (" & TRIM$(STR$(ERR)) & ")" IF EOF(1) THEN STDOUT "End of file returned for TCP connection." IF LEN(buffer) = 0 THEN STDOUT "Empty download buffer." buffer = REMAIN$(temp, $CRLF & $CRLF) temp = EXTRACT$(temp, $CRLF & $CRLF) ' ** Display the header information STDOUT temp ' ** Write the data section to a file OPEN save FOR BINARY AS #2 SETEOF #2 PUT$ #2, buffer CLOSE #2 TCP CLOSE #1 END FUNCTION
[This message has been edited by Chad D. Wood (edited June 18, 2004).]Tags: None
Leave a comment: