首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在goutte中更改goutte属性?

如何在goutte中更改goutte属性?
EN

Stack Overflow用户
提问于 2014-01-27 00:03:01
回答 1查看 974关注 0票数 0
代码语言:javascript
复制
<?php
require_once '/var/www/goutte.phar';
 use Goutte\Client; 


 $guzzle = parent::getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults
$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);
?>

当我运行上面的代码时,我得到一个错误:“当没有活动的类作用域时,无法访问父对象::”。那么,如何从Goutte访问Goutte属性呢?

EN

回答 1

Stack Overflow用户

发布于 2014-02-14 08:35:28

示例的开头似乎假设您正在编写Goutte客户端类的扩展。如果您只是使用该类,则代码片段更类似于:

代码语言:javascript
复制
$client = new Client();
$guzzle = $client->getClient(); //You'll want to pull the Guzzle client out of Goutte to inherit its defaults

$guzzle->setDefaultOption('verify', '/path/to/cacert.pem'); //Set the certificate at @mtdowling recommends
$client->setClient($guzzle); //Tell Goutte to use your modified Guzzle client 

$crawler = $client->request('GET', 'https://ocean.ac-guadeloupe.fr/publinet/resultats'); //Proceed as you were
var_dump($crawler);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21365743

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档