微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

30 秒后无法连接到 chrome“http://127.0.0.1:9515/status”已超时

如何解决30 秒后无法连接到 chrome“http://127.0.0.1:9515/status”已超时

我在 symfony 中使用 panther 从网站抓取数据。检测到我的 chromedriver。但我收到此错误消息“30 秒后无法连接到 chrome(“http://127.0.0.1:9515/status”已超时。)。我尝试更改端口,但什么也没有。

在 CLI 中:“警告:fsockopen():无法连接到 127.0.0.1:9515”

如果有人有想法,我很感兴趣!提前致谢!

我的代码

<?PHP
namespace App\Service;

use invalidargumentexception;
use \Symfony\Component\Panther\Client;
use Symfony\Component\HttpKernel\KernelInterface;

class ScraperService {

    private $appKernel;

    public function __construct(KernelInterface $appKernel)
    {
        $this->appKernel = $appKernel;
    }
    
    public function getDataFromCarrefour(){

        $path = $this->appKernel->getProjectDir().'/drivers\chromedriver.exe';

        $results = array();
        $client = Client::createChromeClient($path,[
            '--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/65.0.3312.0 Safari/537.36"','--headless',]);

        $crawler = $client->request('GET','https://www.carrefour.fr/p/*-3600900006972');

   try{
        $results['ingredients'] = $crawler->filter('#product-detail-page > div.pdp__secondary > div > div > div.secondary-details__left > div.secondary-details-blocks > div:nth-child(4) > div > p')->text(); 
        $results['images'] = $crawler->filter('#data-produit-image > div > div.carousel__wrapper > div.carousel__siema > div > div:nth-child(1) > div > div > img')->attr('src');
        $results['title'] = $crawler->filter('#data-produit-card > div.main-details__pricing > div > div > div > div.pdp-pricing__block-left > div.product-card-price > div > span')->text();
        $results['score'] = $crawler->filter('#data-produit-card > div.main-details__scores > a.product-badge__link.product-badge--flag-nutriscore > picture > img')->attr('src');
        
    }catch (invalidargumentexception $e){
            dd($e);
            $results['error'] = 'EAN unreconized !';
        }
        $client->close();
        
        return $results;
    }
}
?>

“C:\Users\gelinn\Desktop\base-veille\vendor\symfony\panther\src\ProcessManager\WebServerReadinessProbeTrait.PHP”中的 RuntimeExeption(第 82 行):

if ($e) {          
        $message = $e->getMessage();              
    } else {                
        $message = "Status code: $statusCode";        
    }            
    throw new \RuntimeException("Could not connect to $service after $timeout seconds ($message).");          
    }           
    usleep(1000);   

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。