curlrequest
Advanced tools
Comparing version 0.1.5 to 0.1.6
49
index.js
@@ -10,4 +10,3 @@ var child = require('child_process') | ||
var curl_map = { | ||
retries: 'retry' | ||
, timeout: 'max-time' | ||
timeout: 'max-time' | ||
, redirects: 'max-redirs' | ||
@@ -22,2 +21,14 @@ }; | ||
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.905.0 Safari/535.7' | ||
, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)' | ||
, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)' | ||
, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0)' | ||
, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13' | ||
, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6' | ||
, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)' | ||
, 'Opera/9.20 (Windows NT 6.0; U; en)' | ||
, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' | ||
, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; MS-RTC LM 8)' | ||
, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/6.0' | ||
, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_7; en-us) AppleWebKit/533.4 (KHTML, like Gecko) Version/4.1 Safari/533.4' | ||
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.22 (KHTML, like Gecko) Chrome/11.0.683.0 Safari/534.22' | ||
], user_agent_len = user_agents.length; | ||
@@ -46,3 +57,3 @@ | ||
var defaults = options; | ||
return function (options, callback) { | ||
var fn = function (options, callback) { | ||
if (typeof options === 'function') { | ||
@@ -61,4 +72,19 @@ callback = options; | ||
}; | ||
fn.urls = module.exports.urls; | ||
return fn; | ||
} | ||
if (options.retries) { | ||
var remaining = options.retries; | ||
delete options.retries; | ||
return (function curl() { | ||
module.exports(options, function (err) { | ||
if (!err || !--remaining) { | ||
return callback.apply(this, arguments); | ||
} | ||
process.nextTick(curl); | ||
}); | ||
})(); | ||
} | ||
if (typeof options === 'string') { | ||
@@ -216,1 +242,18 @@ options = { url: options }; | ||
/** | ||
* Expose a helper for scraping urls from a page. | ||
*/ | ||
var urls = /(?:href|src|HREF|SRC)=["']?([^"' >]+)/g; | ||
module.exports.urls = function (data, regex) { | ||
var match, matches = []; | ||
while (match = urls.exec(data)) { | ||
if (regex && !regex.test(match[1])) { | ||
continue; | ||
} | ||
matches.push(match[1]); | ||
} | ||
return matches; | ||
}; | ||
{ "name" : "curlrequest", | ||
"description" : "A curl wrapper for node", | ||
"version" : "0.1.5", | ||
"version" : "0.1.6", | ||
"homepage" : "https://github.com/chriso/curlrequest", | ||
@@ -5,0 +5,0 @@ "author" : "Chris O'Hara <cohara87@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10753
235