Skip to content

Commit

Permalink
fetching attachments when problem empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Oct 24, 2021
1 parent 2c0f5d7 commit cf74c8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ private function _extractCodeForces($pcode, $url)
$this->currentProblemCcode = $pcode;
$this->imageIndex = 1;

$this->pro["input"] = null;
$this->pro["output"] = null;
$this->pro["note"] = null;
$this->pro["sample"] = null;
$this->pro["description"] = null;

$response = $this->getCodeForcesResponse($url);
$contentType = $response->headers['content-type'];
$content = $response->body;
Expand Down Expand Up @@ -167,7 +173,15 @@ private function _extractCodeForces($pcode, $url)
}

$descriptionSpecificationDOM = $problemDOM->find('div.problem-statement', 0);
$this->pro["description"] = trim($descriptionSpecificationDOM->innertext);

if(filled(trim(HtmlDomParser::str_get_html($descriptionSpecificationDOM->innertext, true, true, DEFAULT_TARGET_CHARSET, false)->plaintext))) {
$this->pro["description"] = trim($descriptionSpecificationDOM->innertext);
}

if($this->pro["note"] == $this->pro["description"] && $this->pro["description"] == $this->pro["input"] && $this->pro["input"] == $this->pro["output"] && $this->pro["output"] == null) {
$contestID = $this->pro['contest_id'];
return $this->_extractCodeForces($pcode, "https://codeforces.com/gym/$contestID/attachments");
}

$this->pro["note"] = $this->cacheImage(HtmlDomParser::str_get_html($this->pro["note"], true, true, DEFAULT_TARGET_CHARSET, false));
$this->pro["description"] = $this->cacheImage(HtmlDomParser::str_get_html($this->pro["description"], true, true, DEFAULT_TARGET_CHARSET, false));
Expand Down
2 changes: 1 addition & 1 deletion babel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "CodeForces Gym Interface for NOJ",
"license": "MIT",
"repository": "https://github.com/NJUPTAAA/NOJ_Extension_Babel_Gym",
"version": "0.1.2",
"version": "0.1.3",
"website": "https://codeforces.com/gyms",
"custom": {
"css": "resources/custom.css"
Expand Down

0 comments on commit cf74c8e

Please sign in to comment.