节点请求抛出:错误:无效的URI“www.urlworksinbrowser.com”或options.uri是必需的参数

我在Ubuntu 12.04上使用Node v0.10.11。 我不知道我错过了什么使一个urlstream的请求模块工作。 这个程序正在尝试去邮件列表网站,find每个月的下载链接,然后每个月下载一次。

mikeal的自述文件中提到:“第一个参数可以是一个url或一个选项对象,唯一需要的选项是uri,其他所有的都是可选的uri || url – 来自url.parse()的完全限定的uri或parsing的url对象。

如果我打电话给url.parse(www.targeturl.com),我得到[错误:options.uri是必需的参数]如果我不使用url.parse,我得到[错误:无效的URI“www.freelists.org / archive / si-list / 06-2013“](这个链接在我的浏览器中工作得很好)

我把代码缩减到了42行。 任何意见欢迎

var request = require('request'), url = require('url'), stream = require('stream'), cheerio = require('cheerio'), // a reduced jQuery style DOM library Transform = require('stream').Transform var DomStripStream = function(target) { this.target = target; stream.Transform.call(this,{objectMode: true}); } DomStripStream.prototype = Object.create( Transform.prototype, {constructor: {value: DomStripStream}} ) DomStripStream.prototype.write = function () { this._transform.apply(this, arguments); }; DomStripStream.prototype.end = function () { this._transform.apply(this, arguments); this.emit("end"); }; DomStripStream.prototype._transform = function(chunk, encoding, callback) { chunk = chunk ? chunk.toString() : ""; $ = cheerio.load(chunk); domLinks = $(this.target); $(domLinks).each(function (i, link) { currLink = 'www.freelists.org' + $(link).attr('href') // currLink = url.parse(currLink) request(currLink, function (error, response, body) { console.log(error); }) }); } var fs = require("fs"), output = fs.createWriteStream("out.txt"), mainPage = new DomStripStream('td a') request('http://www.freelists.org/archive/si-list'). pipe(mainPage). pipe(output); 

在url中添加http://或https://