php - 项目的刮板循环,如果它是空的则跳过
问题描述
我有一个小问题,我需要你的指导。
我正在尝试使用包含<a>
标签的项目列表来抓取页面。现在<a>
,其中一些项目中缺少标签,并且它返回了一条错误消息:
The current node list is empty.
这是我的代码:
$datas = $mainPage->filter('#accordion div')->each(function($item){
return $results[] = $item->filter('table tr td')->each(function($data, $i) {
$re2[$i] = $data->filter('a')->text();
//I need it to skip when **[a][1]** tag doesn't exist and continue looping
});
});
这是页面项目的视图:
解决方案
推荐阅读
- excel - 错误 ApplicationMaster:用户类抛出异常:java.lang.OutOfMemoryError:GC 开销限制超出 spark-excel
- python - 是否可以让 dask 与 python 多处理 shared_memory 一起工作(BrokenProcessPool 错误)?
- angular - PrimeNg 数据表过滤搜索启动错误分页
- javascript - Firebase 函数与 Set() 上的 Converter Wipes 文档参考
- powerbi - 如何在一个度量中创建两个关联列的不同计数列
- python - 当文本包含'.'时如何进行严格的子字符串搜索?
- java - PBKDF2适合登录密码验证吗?
- c# - Unity C#中的变量别名
- sql - 如何根据用户名和日期返回最近的 id - SQL
- javascript - 如何过滤对象内的数组并返回其中包含最多项目的数组?