Skip to content

Commit

Permalink
fix potential bug when crawler got error
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Aug 25, 2017
1 parent 5a690e9 commit 5b6afd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"name": "Launch File",
"program": "${file}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/server.js"
}
]
}
6 changes: 3 additions & 3 deletions ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const getTicketStatus = (sportsId) => {
return new Promise(async (resolve, reject) => {
try {
const $ = await getCheerio$(`${rootUrl}/schedule/17_TPE_${sportsId}`)
const promises = Array.from($('#schedule-info tr:has(button)').map(async (index, tr) => {
const results = Array.from($('#schedule-info tr:has(button)').map((index, tr) => {
const $tr = $(tr);
const $tds = $tr.find('td')
const ticketUrl = rootUrl + $tr.find('button').attr('onclick').split('\'')[1];
Expand All @@ -31,11 +31,11 @@ const getTicketStatus = (sportsId) => {
url: ticketUrl
}
}));
const results = await Promise.all(promises);
resolve(results);
}
catch (err) {
console.error(err)
console.error(err);
resolve([]);
}
})
}
Expand Down

0 comments on commit 5b6afd2

Please sign in to comment.