Git Product home page Git Product logo

Fatal error: Uncaught TypeError: Argument 1 passed to QL\Services\MultiRequestService::QL\Services\{closure}() must be an instance of GuzzleHttp\Exception\RequestException, instance of GuzzleHttp\Exception\ConnectException given about querylist HOT 3 OPEN

jsonhet avatar jsonhet commented on June 14, 2024
Fatal error: Uncaught TypeError: Argument 1 passed to QL\Services\MultiRequestService::QL\Services\{closure}() must be an instance of GuzzleHttp\Exception\RequestException, instance of GuzzleHttp\Exception\ConnectException given

from querylist.

Comments (3)

jsonhet avatar jsonhet commented on June 14, 2024

之前以为是没传类型的问题,修改后发现问题还是会出现
相关代码:`
use QL\QueryList;
use GuzzleHttp\Psr7\Response;

use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;

    QueryList::rules($rules)->multiGet($urls)
    ->concurrency(5)    // 设置并发数
    ->withOptions(['verify'  => false])
    ->success(function(QueryList $ql, Response $res, $index) use ($rules, $task, $urls){
        $images = array();
        $url = $urls[$index];
        
        try{
            SH_Log::insert($task['id'], '数据爬取成功,处理中。url:'.$url);
        
            // 爬取图片
            if(isset($rules['image'])){
                if(self::isWeichatPost($url)){
                    $rules['image'][1] = 'data-src';
                }

                $images = $ql->find($rules['image'][0])->attrs($rules['image'][1])->all(); 
            }

            // 获取结果
            $data = $ql->rules($rules)->query()->getData()->all();
            $data['url'] = $url;
            
            
            if(!$this->filterCollectorResult($task, $data)){
                SH_Data::deleteByUrl($url);
                $this->filterFail ++;
            }else{
                $this->saveJiebaSpitWord($data);
                $this->saveCollectorResult($task, $data, $images, $rules, $url);                
            }
            
            // 最后一个任务url爬取完毕时
            if($index+1 == count($urls)){
                if($task['run_type'] == 'manual') SH_Task::setTaskStateById($task['id'], false);
                return $this->setSuccessResult($task, count($urls));
            }                          
        }catch(Exception $e){
            SH_Log::insert($task['id'], 'ERROR: 数据爬取失败,'.$e->getMessage());
        }
    })
    ->error(function(QueryList $reason, Exception $err){
        // var_dump($reason, $err);
        SH_Log::insert($task['id'], "ERROR: 数据爬取失败,$url ".$err->getMessage());
    })
    ->send();`

from querylist.

yangfancn avatar yangfancn commented on June 14, 2024

src/Services/MultiRequestService.php

line 55, 这里应该是 GuzzleException

    public function error(Closure $error)
    {
        $this->multiRequest = $this->multiRequest->error(function(GuzzleException $reason, $index) use($error){
            $error($this->ql,$reason, $index);
        });
        return $this;
    }

from querylist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.