php - 无法浏览谷歌云上的图书馆
问题描述
我想使用 lravel 的“Goutte”进行抓取,它在本地环境中成功,但在 Google Cloud 环境中出现错误。可能没有在控制器的“使用”部分中引用。
我参考了这个网站来了解如何使用“Goutte”。
使用的控制器如下
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// Probably not able to refer to this ---------|
use Weidner\Goutte\GoutteFacade as GoutteFacade;
class BookController extends Controller
{
public function index(){
$goutte = GoutteFacade::request('GET', 'https://www.amazon.co.jp/gp/bestsellers/electronics/3946818051?ref_=Oct_BSellerC_3946818051_SAll&pf_rd_p=7019a35e-d4ad-5da4-8fdd-f9f5c8ef9428&pf_rd_s=merchandised-search-10&pf_rd_t=101&pf_rd_i=3946818051&pf_rd_m=AN1VRQENFRJN5&pf_rd_r=61C7KYXHQFEAY80RGM67&pf_rd_r=61C7KYXHQFEAY80RGM67&pf_rd_p=7019a35e-d4ad-5da4-8fdd-f9f5c8ef9428');
$images = [];
$texts = [];
$goutte->filter('.a-dynamic-image')->each(function ($node) use (&$images) {
$images[] = $node->attr('src');
});
$goutte->filter('.p13n-sc-truncate')->each(function ($node) use (&$texts) {
$texts[] = $node->text();
});
$params = [
'images' => $images,
'texts' => $texts,
];
return view('book.index',$params);
}
}
作曲家.json
"require": {
// add
"fabpot/goutte": "^3.3.0",
"weidner/goutte": "^1.6"
},
配置/app.php
'providers' => [
// add
Weidner\Goutte\GoutteServiceProvider::class,
]
'aliases' => [
// add
'Goutte' => Weidner\Goutte\GoutteFacade::class,
]
Postscript
@Hamelraj
此图像与云作曲家更新一致吗?
此外,即使我再次部署该错误也不会改善。识别“gcloud app deploy”在本地再次执行是否正确?
解决方案
推荐阅读
- selenium - Selenium 中的继续会话无法 getAttribute()
- xcode - Xcode 服务器机器人错误“触发器以非零状态 2 退出”
- javascript - Cannot read property of 'onOverviewChange' of undefined
- ios - 如何在反应原生 IOS 中运行一次 GIF?
- django - 加快django rest框架模板渲染性能
- c# - 带有约束的 C# 模板
- python-3.x - 根据特定列年龄从数据框中获取所有唯一行并删除所选行
- javascript - 当 HTML 下拉菜单上的系统下拉菜单变得可见或模糊时,是否会调用任何操作?
- java - Collections.sort() 在编译时显示错误,而 TreeSet 中的 add() 方法在运行时显示
- html - 菜单链接未在 wordpress 的新页面中打开