RequestError: Error: read ECONNRESET nodejs
RequestError: Error: read ECONNRESET nodejs
我尝试使用 nba.com api,但给我那个错误。
"RequestError: Error: read ECONNRESET
at new RequestError (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\errors.js:14:15)
at Request.plumbing.callback (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:87:29)
at Request.RP$callback [as _callback] (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:46:31)
at self.callback (c:\Users\Omer\Desktop\game\node_modules\request\request.js:188:22)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at Request.onRequestError (c:\Users\Omer\Desktop\game\node_modules\request\request.js:884:8)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
From previous event:
at Request.plumbing.init (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:36:28)
at Request.RP$initInterceptor [as init] (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\configure\request2.js:41:27)
at new Request (c:\Users\Omer\Desktop\game\node_modules\request\request.js:130:8)
at request (c:\Users\Omer\Desktop\game\node_modules\request\index.js:54:10)
at requestStats (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats.crawler.js:23:12)
at Object.crawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats.crawler.js:12:12)
at Object.crawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\stats.crawler.js:20:20)
at Object.runCrawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\utils.crawler.js:27:18)
at startCrawl (c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:19:13)
at loadConfig (c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:12:5)
at c:\Users\Omer\Desktop\game\config\lib\mongoose.js:35:21
at
at process._tickCallback (internal/process/next_tick.js:188:7)"
我的代码:
var path = require('path'),
request = require('request-promise'),
format = require('string-template');
module.exports = {
crawl: crawl
};
const STATS_NBA_API = 'http://stats.nba.com/stats/leaguegamelog?Counter=1000&DateFrom=&DateTo=&Direction=DESC&LeagueID=00&PlayerOrTeam=P&Season=2017-18&SeasonType=Regular+Season&Sorter=DATE';
function crawl(options){
return requestStats(STATS_NBA_API)
.then(statsPlayers => { return convertStatsToList(statsPlayers); })
.catch(error =>
console.log(error))
}
function convertStatsToList(statsPlayers){
console.log(statsPlayers)
}
function requestStats(url){
var options = {
method: 'GET',
url: url,
json: true
};
return request(options);
}
function requestStats(url) {
var options = {
method: 'GET',
url: url,
json: true,
headers: {
'Connection': 'keep-alive',
'Accept-Encoding': '',
'Accept-Language': 'en-US,en;q=0.8'
}
};
return request(options);
}
我尝试使用 nba.com api,但给我那个错误。
"RequestError: Error: read ECONNRESET at new RequestError (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\errors.js:14:15) at Request.plumbing.callback (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:87:29) at Request.RP$callback [as _callback] (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:46:31) at self.callback (c:\Users\Omer\Desktop\game\node_modules\request\request.js:188:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (c:\Users\Omer\Desktop\game\node_modules\request\request.js:884:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) From previous event: at Request.plumbing.init (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\lib\plumbing.js:36:28) at Request.RP$initInterceptor [as init] (c:\Users\Omer\Desktop\game\node_modules\request-promise-core\configure\request2.js:41:27) at new Request (c:\Users\Omer\Desktop\game\node_modules\request\request.js:130:8) at request (c:\Users\Omer\Desktop\game\node_modules\request\index.js:54:10) at requestStats (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats.crawler.js:23:12) at Object.crawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats.crawler.js:12:12) at Object.crawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\stats.crawler.js:20:20) at Object.runCrawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\utils.crawler.js:27:18) at startCrawl (c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:19:13) at loadConfig (c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:12:5) at c:\Users\Omer\Desktop\game\config\lib\mongoose.js:35:21 at at process._tickCallback (internal/process/next_tick.js:188:7)"
我的代码:
var path = require('path'),
request = require('request-promise'),
format = require('string-template');
module.exports = {
crawl: crawl
};
const STATS_NBA_API = 'http://stats.nba.com/stats/leaguegamelog?Counter=1000&DateFrom=&DateTo=&Direction=DESC&LeagueID=00&PlayerOrTeam=P&Season=2017-18&SeasonType=Regular+Season&Sorter=DATE';
function crawl(options){
return requestStats(STATS_NBA_API)
.then(statsPlayers => { return convertStatsToList(statsPlayers); })
.catch(error =>
console.log(error))
}
function convertStatsToList(statsPlayers){
console.log(statsPlayers)
}
function requestStats(url){
var options = {
method: 'GET',
url: url,
json: true
};
return request(options);
}
function requestStats(url) {
var options = {
method: 'GET',
url: url,
json: true,
headers: {
'Connection': 'keep-alive',
'Accept-Encoding': '',
'Accept-Language': 'en-US,en;q=0.8'
}
};
return request(options);
}