Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
  • Loading branch information
copyrenzhe committed Apr 7, 2017
1 parent c75dfe4 commit 0730e11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Repositories/Snatch/Biquge.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getNovelList()
/**
* 根据链接初始化单个小说
* @param $link 小说网址
* @return Novel $novel 返回小说实例
* @return mixed Novel $novel 返回小说实例
*/
public function init($link)
{
Expand Down
10 changes: 9 additions & 1 deletion app/Repositories/Snatch/Snatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace App\Repositories\Snatch;

use Log;
use ReflectionClass;

class Snatch
Expand All @@ -35,8 +36,15 @@ protected function send($url, $type = 'GET', $params = false, $encoding = 'gbk')
$params && curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
$html = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if($html === false) {
echo "curl error: " . curl_errno($ch);
Log::error("链接: {$url}, curl失败,error: ". curl_errno($ch) ."请注意查看");
return false;
}
if($httpCode!== 200) {
Log::error("链接: {$url}, curl code不等于200,code: ". curl_errno($ch) ."请注意查看");
return false;
}
curl_close($ch);
return $encoding ? mb_convert_encoding($html, 'UTF-8', $encoding) : $html;
Expand Down

0 comments on commit 0730e11

Please sign in to comment.