diff --git a/packages/vjudge/src/providers/hduoj.ts b/packages/vjudge/src/providers/hduoj.ts index d2a9c8b8b..9bb4f756b 100644 --- a/packages/vjudge/src/providers/hduoj.ts +++ b/packages/vjudge/src/providers/hduoj.ts @@ -65,10 +65,16 @@ export default class HDUOJProvider extends BasicFetcher implements IBasicProvide async getProblem(id: string) { logger.info(id); - const res = await this.get('/showproblem.php') - .query({ pid: id.split('P')[1] }) - .buffer(true) - .charset('gbk'); + let res: any; + try { + res = await this.get('/showproblem.php') + .query({ pid: id.split('P')[1] }) + .buffer(true) + .charset('gbk'); + } catch (e) { + logger.error(`${id} sync failed`); + return; + } const { window: { document } } = new JSDOM(res.text); const images = {}; const files = {}; @@ -128,11 +134,12 @@ export default class HDUOJProvider extends BasicFetcher implements IBasicProvide if (lastMark === 'Sample Input' || lastMark === 'Sample Output') { html += `\n
${node.innerHTML}
\n`; } else { - html += node.innerHTML; + html += `

${node.innerHTML}

`; } } } const tagList = (tag.length === 0) ? [] : [tag]; + // eslint-disable-next-line consistent-return return { title, data: {