我正在运行PHP 7.3.5
和"fabpot/goutte": "^3.2"
。
我正在尝试从链接中删除简介和日期,但是,我一无所获。
在我的最小可行示例下面查找:
<?php
require_once 'vendor/autoload.php';
use Goutte\Client;
$client = new Client();
$url = 'body > div.container > div > div > ul.list-group.mb-5 > a';
$intr = 'body > div:nth-child(3) > div:nth-child(2) > div > table:nth-child(10) > tbody > tr > td > div > div:nth-child(1) > div > div > div > div > table > tbody > tr > th > table:nth-child(4) > tbody > tr > td';
$dat = 'body > div:nth-child(3) > div:nth-child(2) > div > table:nth-child(10) > tbody > tr > td > div > div:nth-child(1) > div > div > div > div > table > tbody > tr > th > table:nth-child(1) > tbody > tr > td:nth-child(1)';
//arrays
$introArr = array();
$urlArr = array();
$crawler = $client->request('GET','https://www.morningbrew.com/daily/2019/11/07');
$intro = $crawler->filter($intr)->each(function($node) {
return $node;
});
$date = $crawler->filter($dat)->each(function($node) {
return $node->html();
});
array_push( $introArr,$intro,$date);
我想回来:
有人建议我在做什么错吗?
感谢您的答复!