var url = require('url');
var result = url.parse('https://www.baidu.com/s?wd=python#123', true);
console.log(result);
Url {
protocol: 'https:', 地址栏协议
slashes: true, 如果协议protocol冒号后跟的是两个斜杠字符,那么值为true
auth: null, url的用户名与密码部分
host: 'www.baidu.com', 一级域名
port: null, 端口号
hostname: 'www.baidu.com', 主机名
hash: '#123', #后面的字符
search: '?wd=python', ?后面的字符
query: [Object: null prototype] { wd: 'python' }, 请求参数
pathname: '/s', 请求路径
path: '/s?wd=python', 请求路径和请求参数组成
href: 'https://www.baidu.com/s?wd=python#123' 完整网址
}