New Socket Object

All things .jsx

Moderator: Paul Tuersley

Post Reply
micpen
Posts: 7
Joined: May 15th, 2012, 1:54 am

May 20th, 2012, 2:49 pm

Hi,
Here are some code to download a (source code ) web page with the socket object and save it on your desktop and open it.
hoping that it may be useful to someone.

//---
var reply = "";
var conn = new Socket;
// access Adobe’s home page
if (conn.open ("www.adobe.com:80")) {
// send a HTTP GET request
conn.write ("GET /index.html HTTP/1.0\n\n");
// and read the server’s reply
reply = conn.read(999999);
conn.close();
}

var file = new File("C:/Users/Michel/Desktop/adobe.htm"); // instead of "Michel" the user name of your computer.
file.encoding = "UTF8";
file.open("w", "TEXT", "????");
// unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
file.write("\uFEFF");
file.lineFeed = "unix";
file.write(reply.toString());
file.close();
file.execute();
//----

Michel :mrgreen:
Post Reply