/app/api/controller/Postbot.php
接口文件放置位置
模块不需要登录, 模块配置哪里直接选择不登录
发布模块的表单字段及说明:
1. book_name 漫画名
2. nick_name 漫画别名
3. tags 分类,多个分类用|隔开
4. author 作者名字
5. end 状态,1代表完结,0代表连载中
6. cover_url 封面图远程地址
7. chapter_name 章节名
8. area_id 地区id
9. images 由图片标签组成的字符串,示例:
自动检测
<img src="http://www.m.com/1.jpg"><img src="http://www.m.com/2.jpg"><img src="http://www.m.com/3.jpg">
11. summary 漫画简介
12. api_key 后台配置的api_key
13. src 用来区别采集源,自己写
14. src_url 用来唯一定义每个漫画,可以是该漫画的url,也可以是该漫画在被采集站的id
15. c_src_url 用来唯一定义每个章节,与src_url同理
<?php namespace apppicontroller; use appmodelAuthor; use appmodelBook; use appmodelPhoto; use thinkController; use thinkRequest; use appmodelChapter; use appservicechapterService; use appservicephotoService; class Postbot { protected $chapterService; protected $photoService; public function initialize() { $this->chapterService = new ppserviceChapterService(); $this->photoService = new ppservicePhotoService(); } public function save(Request $request) { if ($request->isPost()) { $data = $request->param(); $key = $data['api_key']; if (empty($key) || is_null($key)) { return 'api密钥不能为空!'; } if ($key != config('site.api_key')) { return 'api密钥错误!'; } $book = Book::where('book_name', '=', trim($data['book_name']))->where('unique_id', '=', trim($data['unique_id']))->find(); if (!$book) { //如果漫画不存在 $author = Author::where('author_name', '=', trim($data['author']))->find(); if (is_null($author)) {//如果作者不存在 $author = new Author(); $author->author_name = $data['author'] ?: '侠名'; $author->save(); } $book = new Book(); $book->unique_id = $data['unique_id']; $book->author_id = $author->id; $book->author_name = $data['author'] ?: '侠名'; $book->area_id = trim($data['area_id']); $book->book_name = trim($data['book_name']); if (!empty($data['nick_name']) || !is_null($data['nick_name'])) { $book->nick_name = trim($data['nick_name']); } $book->tags = trim($data['tags']); $book->end = trim($data['end']); $book->start_pay = trim($data['start_pay']); $book->money = trim($data['money']); // $info = $this->getImage($data['cover_url'], './img/' . date("Ymd")); $book->cover_url = trim($data['cover_url']); $book->summary = trim($data['summary']); $book->last_time = time(); // $book->update_week = rand(1, 7); // $book->click = rand(1000, 9999); $book->save(); } $map[] = ['chapter_name', '=', trim($data['chapter_name'])]; $map[] = ['book_id', '=', $book->id]; $chapter = Chapter::where($map)->find(); if (!$chapter) { $chapter = new Chapter(); $chapter->chapter_name = trim($data['chapter_name']); $chapter->book_id = $book->id; $lastChapterOrder = 0; if ($data['chapter_order']) { $chapter->chapter_order = (int)$data['chapter_order']; } else { $lastChapter = $this->getLastChapter($book['id']); if ($lastChapter) { $lastChapterOrder = $lastChapter->chapter_order; } $chapter->chapter_order = $lastChapterOrder + 1; } $chapter->update_time = time(); $chapter->save(); } $book->last_time = time(); $book->save(); $preg = '/srcs*=s*['"]?([^'"]*)['"]?/i'; preg_match_all($preg, $data['images'], $img_urls); $lastOrder = 0; $lastPhoto = $this->getLastPhoto($chapter->id); if ($lastPhoto) { $lastOrder = $lastPhoto->pic_order + 1; } foreach ($img_urls[1] as $img_url) { $photo = new Photo(); $photo->chapter_id = $chapter->id; $photo->pic_order = $lastOrder; // $info = $this->getImage($img_url, './img/' . date("Ymd")); $photo->img_url = $img_url; $photo->save(); $lastOrder++; } echo "操作成功"; } } public function getLastChapter($book_id) { return Chapter::where('book_id', '=', $book_id)->order('chapter_order', 'desc')->limit(1)->find(); } public function getLastPhoto($chapter_id) { return Photo::where('chapter_id', '=', $chapter_id)->order('id', 'desc')->limit(1)->find(); } /*功能:php完美实现下载远程图片保存到本地 *参数:文件url,保存文件目录,保存文件名称,使用的下载方式 *当保存文件名称为空时则使用远程文件原来的名称 */ function getImage($url, $save_dir = '/public/img/', $filename = '', $type = 1) { if (trim($url) == '') { return array('file_name' => '', 'save_path' => '', 'error' => 1); } if (trim($save_dir) == '') { $save_dir = './'; } $url = str_replace('jpg ', 'jpg', $url); file_put_contents("result.txt", "url:" . $url . " ", FILE_APPEND); if (trim($filename) == '') {//保存文件名 $ext = strrchr($url, '.'); // if($ext!='.gif'&&$ext!='.jpg'){ // return array('file_name'=>'','save_path'=>'','error'=>3); // } $filename = time() . rand(100000, 999999) . $ext; } if (0 !== strrpos($save_dir, '/')) { $save_dir .= '/'; } //创建保存目录 if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) { return array('file_name' => '', 'save_path' => '', 'error' => 5); } //获取远程文件所采用的方法 if ($type) { $img =$this-> http_curl($url); !$img && $img = $this->http_curl($url); !$img && $img = $this->http_curl($url); } else { ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); } //$size=strlen($img); // dump($img);die;/ //文件大小 // dump($save_dir.$filename);die; $fp2 = @fopen($save_dir . $filename, 'a'); fwrite($fp2, $img); fclose($fp2); unset($img, $url); return array('file_name' => $filename, 'save_path' => str_replace('./', '/', $save_dir . $filename), 'error' => 0); } function http_curl($url) { $ch = curl_init(); $timeout = 5; $aHeader = array('Referer: https://www.baidu.com/'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $img = curl_exec($ch); curl_close($ch); return $img; } }相关知识点: 小碗熊cms5.0 小碗熊cms5.0api
- 1蓝天采集器有没有可能增加这么一个“采集筛选”的功能?
- 2蓝天采集器拼接网址问题--卡壳了
- 3PbootCMS中文域名获取授权码注意点
- 4蓝天采集器官方的云平台cms发布插件要怎么使用
- 5PbootCMS内容详情页自定义模板文件
- 6蓝天采集器支持苹果cms吗
- 7蓝天采集器蓝天采集器安装好后仍提示安装
- 8蓝天采集器百度知道问题列表页测试抓取获取不到问题列表?
- 9蓝天采集器自动采集具体怎么用呢,需要服务器支持什么
- 10蓝天采集器能不能采集内容分页呀。我看了好像不行
- 11蓝天采集器如何卸载删除操作教程
- 12蓝天采集器新手求问 缩略图在列表页内容页没有缩略图怎么办
- 13蓝天采集器WordPress BUG 站点固定连接
- 14蓝天采集器部分采集发布成功,部分提示错误,求解决,
- 15蓝天采集器请问一下 多级网址获取 应该怎么使用
- 16蓝天采集器wordpress发布插件BUG
- 17蓝天采集器内容页数据处理问题
- 18RGCMS在线安装操作教程
- 19蓝天采集器关键json采集的问题
- 20蓝天采集器采集器自动发帖的时间与论坛系统的发帖时间怎么对接?
-
蓝天采集器这种页面不能采集吗
https://movie.douban.com/j/search_subjects?type=movie&tag=%E6%9C%80%E6%96%B0&page_limit=500&page_start=0起始页网···
-
FastAdmin问答社区系统火车头···
FastAdmin是一款基于ThinkPHP5+Bootstrap开发的极速后台开发框架。今天蜀戎给大家讲解下如何用火车头来采集入库;这个系统呢缩略图一定要本地化,要不然前端不显示,内容中的图片可以远程倒链。游客访问:关闭=0 &···
-
蓝天采集器自动采集-访问触发 里面的···
需在您的网站底部模板中加入一条html代码: <script src="http://domin.mydomin.com/index.php?m=admin&c=index&a=caiji">···
-
蓝天采集器发布设置,点击保存后,没有···
发布设置,点击保存后,没有任何变化 ,类似刷新一下后,还是没有变化 之后又试了下, 用nginx的 可以正常保存 Apache的不可以 apache-2.4 mysql-generic-5.5 php-7.1 LA···
-
蓝天采集器PHP7的版本什么时候出
目前我们的服务器环境是PHP7的,想用蓝天采集器,用不了 临时解决:把文件上传到SkycaijiApp/Admin/Controller 覆盖可以访问后台