nodeJs第一天

queryString 模块


const querystring=require('querystring');
var url=querystring.parse('user=duanli&password=123');
console.log(url); //{ user: 'duanli', password: '123' }

URL 模块


const urllib=require('url');

var obj=urllib.parse('http://www.baidu.con/index?user=duanli&password=123'true);
console.log(obj);

/* 返回 Url {
protocol: 'http:',
slashes: true,
auth: null,
host: 'www.baidu.con',
port: null,
hostname: 'www.baidu.con',
hash: null,
search: '?user=duanli&password=123',
query: 'user=duanli&password=123',
pathname: '/index',
path: '/index?user=duanli&password=123',
href: 'http://www.baidu.con/index?user=duanli&password=123' }
*/

你可能感兴趣的:(nodeJs第一天)