ID like to find out how to download a file from a webpage to my PC using Winsoc. Any ideas?
Printable View
ID like to find out how to download a file from a webpage to my PC using Winsoc. Any ideas?
Assuming you already know the basics of Winsock, connect to a web server at port 80 and send the following string:
"GET /page.html HTTP/1.0" & vbcrlf & vbcrlf
The incoming data will be the page. You'll have to keep appending it to a string until the connection closes - the file can come in "chunks". Then strip out the HTTP headers (everything up to and including the first two vbcrlf's), and save it to disk.
What does the folowing mean and what do I need to do o correct it.
This is what I receive when sending the string you suggested.
HTTP/1.0 401 Unauthorized
WWW-Authenticate: Basic realm="FW-1. Reason: no user Server "
Content-Type: text/html
Content-Length: 323
<TITLE>Error</TITLE>
<BODY>
<H1>Error 401</H1>
FW-1 at primaryfw1: Unauthorized to access the document.<BR><BR><LI>Authorization is needed for FW-1.<BR><BR><LI>The authentication required by FW-1 for the user is: <STRONG>unknown</STRONG>.<BR><BR><LI>Reason for failure of last attempt: <STRONG>no user</STRONG>
</BODY>
It means you need to send a valid username and password to access the page.
How do I sent the user name and password?