[Node.js]request

request是node.js中類似curl功能,主要是用來模擬HTTP的動作

安裝

npm install request

基本用法

request("http://google.com", function(error, response, body) {
  console.log(body);
});

一般GET用法

request({
    uri: "http://www.yahoo.com.tw",
    method: "GET",
    timeout: 10000,
    followRedirect: true,
    maxRedirects: 10
}, function(error, response, body) {
    console.log(body);
});

POST用法

request({
    uri: "http://www.yahoo.com.tw",
    method: "POST",
    form: {
        name: "Bob"
    }
}, function(error, response, body) {
    console.log(body);
});

下載檔案

var request = require("request"),
    fs      = require("fs");

request.get('http://url/img.jpg').pipe(fs.createWriteStream('img.jpg'));

[PHP]phpQuery

[Bootstrap]Bootstrap 3 datetimepicker