Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
micpen
Topic Author
Posts: 7
Joined: Tue May 15, 2012 1:54 am

New Socket Object

Sun May 20, 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:

Who is online

Users browsing this forum: No registered users and 3 guests