Skip to content

Commit

Permalink
update snatch & format code
Browse files Browse the repository at this point in the history
  • Loading branch information
copyrenzhe committed Jun 3, 2017
1 parent d865aba commit c66ef5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/SiteMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public function handle()
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode===200){
if ($httpcode === 200) {
session(['siteMonitor' => 0]);
} else {
$error_times = session('siteMonitor') + 1;
session(['siteMonitor' => $error_times]);
}
//连续一个小时访问异常
if(session('siteMonitor') > 5){
if (session('siteMonitor') > 5) {
Event::fire(new MailPostEvent('system', '网站访问异常', array()));
session(['siteMonitor' => 0]);
}
Expand Down
10 changes: 6 additions & 4 deletions app/Repositories/Snatch/Biquge.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function snatch(Novel $novel)
$contents = $this->multi_send_test($splice_list[1], self::DOMAIN . $novel->source_link, $this->page_size, 'utf-8');
$temp = [];
foreach ($contents as $k => $html) {
preg_match('/var readid = "(.*?)"/s', $html, $read_match);
preg_match('/addBookMark\((\d+),.*?\)/s', $html, $read_match);
if (@$read_match[1]) {
$biquge_id = $read_match[1];
$content = $this->getChapterContent($html);
Expand All @@ -344,10 +344,12 @@ public function snatch(Novel $novel)
$value_array = [];
$now = Carbon::now();
foreach ($splice_list[2] as $k => $name) {
$idArr = explode('.', $splice_list[1][$k]);
$biquge_id = $idArr[0];
$biquge_idArr = explode('.', $splice_list[1][$k]);
$biquge_idChunk = explode('/', $biquge_idArr[0]);
$biquge_id = end($biquge_idChunk);
$link = $splice_list[1][$k];
$value_array[] = [
'source_link' => self::DOMAIN . $novel->source_link . $splice_list[1][$k],
'source_link' => self::DOMAIN . $novel->source_link . $link,
'name' => $name,
'content' => @$temp[$biquge_id],
'novel_id' => $novel->id,
Expand Down

0 comments on commit c66ef5b

Please sign in to comment.