1 Star 0 Fork 1

董志强 / VideoSpider

forked from 0-hun / VideoSpider 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

php命令行爬虫,支持sohu、iqiyi、youku的视频分类、列表抓取,支持自定义配置抓取

Install

git clone https://git.oschina.net/man0sions/VideoSpider.git
composer install

useage

1:抓取sohu

在命令行输入

mysql数据结构在 public/demo.sql

php public/index.php  sohu

2:自定义爬虫实现

继承src\base\api\Command\Spider 抽象类,并实现doSpider 方法

例如:


/**
 * Class Sohu
 * 抓取sohu的类,继承spider
 * 实现playlist抓取,并保存
 * 实现videos抓取,并保存
 *
 * @package src\commands
 */
class Sohu extends Spider
{
    private $rs_video = 4;
    private $site = 1;
    private $spider_data;

    function __destruct()
    {
//        var_dump(__CLASS__."==>__destruct\n");
    }

    function __construct()
    {
        $this->spider_data = new SohuSpiderData(new SohuFormatStrategy());
    }

    /**
     * @param $url
     * @param $firstcategoryid
     * @return bool
     * @throws AppException
     */
    function doSpider($url, $firstcategoryid)
    {

        $request = new HttpRequest($url,new RandUseragentFetch());
        $res = json_decode($request->fetch());
        if($res->status!=200)
        {
            echo "==>fetch error:{$res}\n";
            return false;
        }

        if(count($res->data->videos)==0)
        {
            echo "==>data empty\n";
            return false;
        }

        foreach ($res->data->videos as $key => $val) {
            $this->savePlaylist($val, $firstcategoryid);
        }
    }

    /**
     * 把sohu api返回的数据视频据列表封住成ThirdPlaylist 对象 然后在对ThirdPlaylist 进行 save(insert / update)
     *
     * @param $item
     * @param $firstcategoryid
     * @throws AppException
     */
    private function savePlaylist($item, $firstcategoryid)
    {
       


    }

    /**
     * 把sohu api返回的剧集信息封住成 ThirdVideo 对象,然后对 ThirdVideo 进行 save(insert / update)
     * @param $playlist
     * @return int
     */
    private function saveVideos($playlist)
    {
       
    }
}
The MIT License (MIT) Copyright (c) 2016 man0sions Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

php命令行爬虫,支持sohu、iqiyi、youku的视频分类、列表抓取,支持自定义配置抓取 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/dong_zhi_qiang/VideoSpider.git
git@gitee.com:dong_zhi_qiang/VideoSpider.git
dong_zhi_qiang
VideoSpider
VideoSpider
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891