Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vjudge: Optimize hduoj vjudge problem description #851

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
Loading