Skip to content

Commit

Permalink
use grab_page instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Oct 23, 2021
1 parent feaa2e9 commit 0f0a4f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
18 changes: 10 additions & 8 deletions Judger.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ public function __construct()
public function judge($row)
{
try {
$sub=[];
$res=Requests::get('https://vijos.org/records/'.$row['remote_id'], ['Referer' => 'https://vijos.org'], [
'verify' => babel_path("Cookies/cacert.pem")
$sub = [];
$res = $this->grab_page([
'site' => 'https://vijos.org/records/'.$row['remote_id'],
'oj' => 'vijos',
]);
preg_match('/<span class="record-status--text \w*">\s*(.*?)\s*<\/span>/', $res->body, $match);
preg_match('/<span class="record-status--text \w*">\s*(.*?)\s*<\/span>/', $res, $match);
$status=$match[1];
if (!array_key_exists($status, $this->verdict)) {
return;
}
if ($match[1]=='Compile Error') {
preg_match('/<pre class="compiler-text">([\s\S]*?)<\/pre>/', $res->body, $match);
preg_match('/<pre class="compiler-text">([\s\S]*?)<\/pre>/', $res, $match);
$sub['compile_info']=html_entity_decode($match[1], ENT_QUOTES);
}
$sub['verdict']=$this->verdict[$status];
preg_match('/<dt>分数<\/dt>\s*<dd>(\d+)<\/dd>/', $res->body, $match);
preg_match('/<dt>分数<\/dt>\s*<dd>(\d+)<\/dd>/', $res, $match);
$isOI=$row['cid'] && $this->contestModel->rule($row['cid'])==2;
if ($isOI) {
$sub['score']=$match[1];
Expand All @@ -62,14 +63,14 @@ public function judge($row)
$sub['remote_id']=$row['remote_id'];
if ($sub['verdict']!="Submission Error" && $sub['verdict']!="Compile Error") {
$maxtime=0;
preg_match_all('/<td class="col--time">(?:&ge;)?(\d+)ms<\/td>/', $res->body, $matches);
preg_match_all('/<td class="col--time">(?:&ge;)?(\d+)ms<\/td>/', $res, $matches);
foreach ($matches[1] as $match) {
if ($match>$maxtime) {
$maxtime=$match;
}
}
$sub['time']=$maxtime;
preg_match('/<dt>峰值内存<\/dt>\s*<dd>(?:&ge;)?([\d.]+) ([KM])iB<\/dd>/', $res->body, $match);
preg_match('/<dt>峰值内存<\/dt>\s*<dd>(?:&ge;)?([\d.]+) ([KM])iB<\/dd>/', $res, $match);
$memory=$match[1];
if ($match[2]=='M') {
$memory*=1024;
Expand All @@ -82,6 +83,7 @@ public function judge($row)

$this->submissionModel->updateSubmission($row['sid'], $sub);
} catch (Exception $e) {
Log::alert($e);
}
}
}
1 change: 1 addition & 0 deletions Submitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\OJModel;
use Illuminate\Support\Facades\Validator;
use Requests;
use Exception;

class Submitter extends Curl
{
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": "Vijos interface for NOJ",
"license": "MIT",
"repository": "https://github.com/NJUPTAAA/NOJ_Extension_Vijos",
"version": "0.2.2",
"version": "0.2.3",
"website": "https://vijos.org/",
"custom": {
"css": "resources/custom.css"
Expand Down

0 comments on commit 0f0a4f7

Please sign in to comment.