|
@@ -80,46 +80,46 @@ |
|
|
block discarded – undo |
|
80
|
80
|
|
|
81
|
81
|
public function crawler($con) |
|
82
|
82
|
{ |
|
83
|
|
- if($con == "all") { |
|
84
|
|
- return ; |
|
|
83
|
+ if ($con=="all") { |
|
|
84
|
+ return; |
|
85
|
85
|
} |
|
86
|
|
- $this->con = $con; |
|
87
|
|
- $this->imgi = 1; |
|
88
|
|
- $problemModel = new ProblemModel(); |
|
89
|
|
- $res = Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
90
|
|
- if (strpos("No such problem",$res->body) !== false) { |
|
|
86
|
+ $this->con=$con; |
|
|
87
|
+ $this->imgi=1; |
|
|
88
|
+ $problemModel=new ProblemModel(); |
|
|
89
|
+ $res=Requests::get("http://acm.hdu.edu.cn/showproblem.php?pid={$con}"); |
|
|
90
|
+ if (strpos("No such problem", $res->body)!==false) { |
|
91
|
91
|
header('HTTP/1.1 404 Not Found'); |
|
92
|
92
|
die(); |
|
93
|
93
|
} |
|
94
|
|
- else if(strpos("Invalid Parameter.",$res->body) !== false) { |
|
|
94
|
+ else if (strpos("Invalid Parameter.", $res->body)!==false) { |
|
95
|
95
|
header('HTTP/1.1 404 Not Found'); |
|
96
|
96
|
die(); |
|
97
|
97
|
} |
|
98
|
98
|
else { |
|
99
|
|
- $this->pro['pcode'] = "HDU".$con; |
|
100
|
|
- $this->pro['OJ'] = 8; |
|
101
|
|
- $this->pro['contest_id'] = null; |
|
102
|
|
- $this->pro['index_id'] = $con; |
|
103
|
|
- $this->pro['origin'] = "http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
104
|
|
- $this->pro['title'] = self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/",$res->body); |
|
105
|
|
- $this->pro['time_limit'] = self::find('/Time Limit:.*\/(.*) MS/',$res->body); |
|
106
|
|
- $this->pro['memory_limit'] = self::find('/Memory Limit:.*\/(.*) K/',$res->body); |
|
107
|
|
- $this->pro['solved_count'] = self::find("/Accepted Submission(s): ([\d+]*?)/",$res->body); |
|
|
99
|
+ $this->pro['pcode']="HDU".$con; |
|
|
100
|
+ $this->pro['OJ']=8; |
|
|
101
|
+ $this->pro['contest_id']=null; |
|
|
102
|
+ $this->pro['index_id']=$con; |
|
|
103
|
+ $this->pro['origin']="http://acm.hdu.edu.cn/showproblem.php?pid={$con}"; |
|
|
104
|
+ $this->pro['title']=self::find("/<h1 style='color:#1A5CC8'>([\s\S]*?)<\/h1>/", $res->body); |
|
|
105
|
+ $this->pro['time_limit']=self::find('/Time Limit:.*\/(.*) MS/', $res->body); |
|
|
106
|
+ $this->pro['memory_limit']=self::find('/Memory Limit:.*\/(.*) K/', $res->body); |
|
|
107
|
+ $this->pro['solved_count']=self::find("/Accepted Submission(s): ([\d+]*?)/", $res->body); |
|
108
|
108
|
$this->pro['input_type']='standard input'; |
|
109
|
109
|
$this->pro['output_type']='standard output'; |
|
110
|
|
- $this->pro['description'] = $this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body), true, true, DEFAULT_TARGET_CHARSET, false)); |
|
111
|
|
- $this->pro['input'] = self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
112
|
|
- $this->pro['output'] = self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU",$res->body); |
|
113
|
|
- $this->pro['sample'] = []; |
|
114
|
|
- $this->pro['sample'][] = [ |
|
115
|
|
- 'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body), |
|
116
|
|
- 'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body) |
|
|
110
|
+ $this->pro['description']=$this->cacheImage(HtmlDomParser::str_get_html(self::find("/Problem Description.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body), true, true, DEFAULT_TARGET_CHARSET, false)); |
|
|
111
|
+ $this->pro['input']=self::find("/<div class=panel_title align=left>Input.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
|
112
|
+ $this->pro['output']=self::find("/<div class=panel_title align=left>Output.*<div class=panel_content>(.*)<\/div><div class=panel_bottom>/sU", $res->body); |
|
|
113
|
+ $this->pro['sample']=[]; |
|
|
114
|
+ $this->pro['sample'][]=[ |
|
|
115
|
+ 'sample_input'=>self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU", $res->body), |
|
|
116
|
+ 'sample_output'=>self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU", $res->body) |
|
117
|
117
|
]; |
|
118
|
118
|
// $this->pro['sample']['sample_input'] = self::find("/<pre><div.*>(.*)<\/div><\/pre>/sU",$res->body); |
|
119
|
119
|
// $this->pro['sample']['sample_output'] = self::find("/<div.*>Sample Output<\/div><div.*><pre><div.*>(.*)<\/div><\/pre><\/div>/sU",$res->body); |
|
120
|
|
- $this->pro['note'] = self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU",$res->body); |
|
121
|
|
- $this->pro['source'] = strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU",$res->body)); |
|
122
|
|
- $this->pro['force_raw'] = 0; |
|
|
120
|
+ $this->pro['note']=self::find("/<i>Hint<\/i><\/div>(.*)<\/div><i style='font-size:1px'>/sU", $res->body); |
|
|
121
|
+ $this->pro['source']=strip_tags(self::find("/<div class=panel_title align=left>Source<\/div> (.*)<div class=panel_bottom>/sU", $res->body)); |
|
|
122
|
+ $this->pro['force_raw']=0; |
|
123
|
123
|
$problem=$problemModel->pid($this->pro['pcode']); |
|
124
|
124
|
|
|
125
|
125
|
if ($problem) { |