如果“< ul>”,如何刮除“< ul>”下的内容?没有课 [英] How do you scrape the content under “<ul>” if "<ul>" does not have class
问题描述
我试图获取 ul
下的内容我尝试了下面的代码,当我执行脚本时,它告诉我链接的总量,但它没有然后进一步刮擦。
如果ul有一个类,请说< ul class =list-group>
我只是这样做
Am trying to get the content under "ul
" I tried the below code, when I execute the script it tells me the total amount of links but it doesn't scrape further then that.
If the ul had a class let say <ul class="list-group">
I would just simply do this
foreach($html->find('.list-group a') as $element)
所以我的问题是如何让刮刀废弃如果 ul
没有类,则 ul
下的链接。在此先感谢。
这是我试图抓取的内容片段。
Snipt site·GitHub [ ^ ]
我尝试过:
So my question is how do I get the scraper to scrap the links under "ul
" if the "ul
" doesn't have a class. Thanks in advance.
Here is the content snippet am trying to scrape.
Snipt site · GitHub[^]
What I have tried:
else {
$html = get_web_page(SITE2_BASE_URL . $path);
$html = str_get_html($html);
$result = array();
foreach($html->find('.series a') as $element) {
$result[] = array('title'=> $element->plaintext, 'href'=> $element->href);
}
推荐答案
html-> find(' .list-group a') as
html->find('.list-group a') as
element)
所以我的问题是,如果 ul $,如何让刮刀废弃
ul
下的链接c $ c>没有课程。在此先感谢。
这是我试图抓取的内容片段。
Snipt site·GitHub [ ^ ]
我尝试过:
So my question is how do I get the scraper to scrap the links under "ul
" if the "ul
" doesn't have a class. Thanks in advance.
Here is the content snippet am trying to scrape.
Snipt site · GitHub[^]
What I have tried:
else {
html = get_web_page(SITE2_BASE_URL。
html = get_web_page(SITE2_BASE_URL .
这篇关于如果“< ul>”,如何刮除“< ul>”下的内容?没有课的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!