小编use*_*212的帖子

从抓取的网页获取页面标题

var http = require('http');
var urlOpts = {host: 'www.nodejs.org', path: '/', port: '80'};
http.get(urlOpts, function (response) {
response.on('data', function (chunk) {
var str=chunk.toString();
var re = new RegExp("(<\s*title[^>]*>(.+?)<\s*/\s*title)\>", "g")
console.log(str.match(re));
});

});
Run Code Online (Sandbox Code Playgroud)

产量

user @ dev~ $ node app.js ['node.js'] null null

我只需要获得头衔.

node.js

10
推荐指数
1
解决办法
3964
查看次数

标签 统计

node.js ×1