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));
});
});
[email protected] ~ $ node app.js [ 'node.js' ] null null
我只需要拿到冠军。
@argonius在他的示例中有一个好处,那就是除了'g'之外,您应该也可以使用'i'标志来使正则表达式不区分大小写(因为'
不适用于SPA网页。你应该使用谷歌浏览器之类的无头浏览器 –