Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/vjudge/src/providers/hduoj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe catch 403 only?

return;
}
const { window: { document } } = new JSDOM(res.text);
const images = {};
const files = {};
Expand Down Expand Up @@ -128,11 +134,12 @@ export default class HDUOJProvider extends BasicFetcher implements IBasicProvide
if (lastMark === 'Sample Input' || lastMark === 'Sample Output') {
html += `\n<pre><code class="language-${markNext}${preId}">${node.innerHTML}</code></pre>\n`;
} else {
html += node.innerHTML;
html += `<p>${node.innerHTML}</p>`;
}
}
}
const tagList = (tag.length === 0) ? [] : [tag];
// eslint-disable-next-line consistent-return
return {
title,
data: {
Expand Down