如何抓取一个没有类的特定<ul>标签li链接?

时间:2018-01-29 06:18:11

标签: php html simple-html-dom

我需要使用我的脚本来抓取此特定li元素中的ul个链接。那是在<div class="series">

之下

我在下面尝试过此代码。当我执行脚本时,它获取链接的总量并显示第一个链接“/ category / 25-sai-no-joshikousei”的“处理链接”,但不会删除它或任何链接。那么如何让我的脚本抓取特定<ul>标记元素下的所有链接。

Image of results when executed script

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);
        }
    }

此处的完整脚本代码:https://codeshare.io/5PzpJX

这是我不想刮擦链接的片段。

<div class="main_body">
  <div class="main_body_black">
    <div class="anime_name ongoing">
      <div class="anime_name_img_ongoing"></div>
      <h2>ongoing series</h2>
    </div>
    <div class="series">
      <!-- begon -->
      <div id="scrollbar2">
        <div class="scrollbar">
          <div class="track">
            <div class="thumb">
              <div class="end"></div>
            </div>
          </div>
        </div>
        <div class="viewport">
          <div class="overview">
            <nav class="menu_series cron">
              <ul>
                <li><a href="/category/25-sai-no-joshikousei" title="25-sai no Joshikousei">25-sai no Joshikousei</a></li>
                <li><a href="/category/3-gatsu-no-lion-2nd-season" title="3-gatsu no Lion 2nd Season">3-gatsu no Lion 2nd Season</a></li>
                <li><a href="/category/aggressive-retsuko" title="Aggressive Retsuko">Aggressive Retsuko</a></li>
                <li><a href="/category/aikatsu-stars" title="Aikatsu Stars!">Aikatsu Stars!</a></li>
                <li><a href="/category/basilisk-ouka-ninpouchou" title="Basilisk: Ouka Ninpouchou">Basilisk: Ouka Ninpouchou</a></li>
                <li><a href="/category/basilisk-ouka-ninpouchou-dub" title="Basilisk: Ouka Ninpouchou (Dub)">Basilisk: Ouka Ninpouchou (Dub)</a></li>
                <li><a href="/category/beatless" title="Beatless">Beatless</a></li>
                <li><a href="/category/beyblade-burst-god" title="Beyblade Burst God">Beyblade Burst God</a></li>
                <li><a href="/category/black-clover-tv" title="Black Clover (TV)">Black Clover (TV)</a></li>
                <li><a href="/category/black-clover-tv-dub" title="Black Clover (TV) (Dub)">Black Clover (TV) (Dub)</a></li>
                <li><a href="/category/bonobono-2016" title="Bonobono (2016)">Bonobono (2016)</a></li>
                <li><a href="/category/boruto-naruto-next-generations" title="Boruto: Naruto Next Generations">Boruto: Naruto Next Generations</a></li>
                <li><a href="/category/cardcaptor-sakura-clear-card-hen" title="Cardcaptor Sakura: Clear Card-hen">Cardcaptor Sakura: Clear Card-hen</a></li>
                <li><a href="/category/cardcaptor-sakura-clear-card-hen-dub" title="Cardcaptor Sakura: Clear Card-hen (Dub)">Cardcaptor Sakura: Clear Card-hen (Dub)</a></li>
                <li><a href="/category/cardfight-vanguard-g-z" title="Cardfight!! Vanguard G: Z">Cardfight!! Vanguard G: Z</a></li>
                <li><a href="/category/cinderella-girls-gekijou-2nd-season" title="Cinderella Girls Gekijou 2nd Season">Cinderella Girls Gekijou 2nd Season</a></li>
                <li><a href="/category/citrus" title="Citrus">Citrus</a></li>
                <li><a href="/category/citrus-dub" title="Citrus (Dub)">Citrus (Dub)</a></li>
                <li><a href="/category/classicaloid-2nd-season" title="ClassicaLoid 2nd Season">ClassicaLoid 2nd Season</a></li>
                <li><a href="/category/closers-side-blacklambs" title="Closers: Side Blacklambs">Closers: Side Blacklambs</a></li>
                <li><a href="/category/crayon-shin-chan" title="Crayon Shin Chan">Crayon Shin Chan</a></li>
                <li><a href="/category/dagashi-kashi-2" title="Dagashi Kashi 2">Dagashi Kashi 2</a></li>
                <li><a href="/category/dame-x-prince-anime-caravan" title="Dame x Prince Anime Caravan">Dame x Prince Anime Caravan</a></li>
                <li><a href="/category/darling-in-the-franxx" title="Darling in the FranXX">Darling in the FranXX</a></li>
                <li><a href="/category/death-march-kara-hajimaru-isekai-kyousoukyoku" title="Death March kara Hajimaru Isekai Kyousoukyoku">Death March kara Hajimaru Isekai Kyousoukyoku</a></li>
                <li><a href="/category/detective-conan" title="Detective Conan">Detective Conan</a></li>
                <li><a href="/category/dragon-ball-super" title="Dragon Ball Super">Dragon Ball Super</a></li>
                <li><a href="/category/dragon-ball-super-dub" title="Dragon Ball Super (Dub)">Dragon Ball Super (Dub)</a></li>
                <li><a href="/category/emiya-san-chi-no-kyou-no-gohan" title="Emiya-san Chi no Kyou no Gohan">Emiya-san Chi no Kyou no Gohan</a></li>
                <li><a href="/category/enmusubi-no-youko-chan" title="Enmusubi no Youko-chan">Enmusubi no Youko-chan</a></li>
                <li><a href="/category/fateextra-last-encore" title="Fate/Extra Last Encore">Fate/Extra Last Encore</a></li>
                <li><a href="/category/flowering-heart" title="Flowering Heart">Flowering Heart</a></li>
                <li><a href="/category/folktales-from-japan-season-2" title="Folktales from Japan Season 2">Folktales from Japan Season 2</a></li>
                <li><a href="/category/future-card-buddyfight-battsu" title="Future Card Buddyfight Battsu">Future Card Buddyfight Battsu</a></li>
                <li><a href="/category/gakuen-babysitters" title="Gakuen Babysitters">Gakuen Babysitters</a></li>
                <li><a href="/category/garo-vanishing-line" title="Garo: Vanishing Line">Garo: Vanishing Line</a></li>
                <li><a href="/category/garo-vanishing-line-dub" title="Garo: Vanishing Line (Dub)">Garo: Vanishing Line (Dub)</a></li>
                <li><a href="/category/gdmen" title="gdMen">gdMen</a></li>
                <li><a href="/category/gin-no-guardian-2nd-season" title="Gin no Guardian 2nd Season">Gin no Guardian 2nd Season</a></li>
                <li><a href="/category/gintama-shirogane-no-tamashii-hen" title="Gintama.: Shirogane no Tamashii-hen">Gintama.: Shirogane no Tamashii-hen</a></li>
                <li><a href="/category/grancrest-senki" title="Grancrest Senki">Grancrest Senki</a></li>
                <li><a href="/category/gundam-build-fighters-battlogue" title="Gundam Build Fighters: Battlogue">Gundam Build Fighters: Battlogue</a></li>
                <li><a href="/category/hakata-tonkotsu-ramens" title="Hakata Tonkotsu Ramens">Hakata Tonkotsu Ramens</a></li>
                <li><a href="/category/hakata-tonkotsu-ramens-dub" title="Hakata Tonkotsu Ramens (Dub)">Hakata Tonkotsu Ramens (Dub)</a></li>
                <li><a href="/category/hakumei-to-mikochi" title="Hakumei to Mikochi">Hakumei to Mikochi</a></li>
                <li><a href="/category/hakyuu-houshin-engi" title="Hakyuu Houshin Engi">Hakyuu Houshin Engi</a></li>
                <li><a href="/category/hataraku-onii-san" title="Hataraku Onii-san!">Hataraku Onii-san!</a></li>
                <li><a href="/category/henkei-shoujo" title="Henkei Shoujo">Henkei Shoujo</a></li>
                <li><a href="/category/hitori-no-shita-the-outcast-2nd-season" title="Hitori no Shita: The Outcast 2nd Season">Hitori no Shita: The Outcast 2nd Season</a></li>
                <li><a href="/category/hugtto-precure" title="Hugtto! Precure">Hugtto! Precure</a></li>
                <li><a href="/category/idol-time-pripara" title="Idol Time PriPara">Idol Time PriPara</a></li>
                <li><a href="/category/idolish7" title="IDOLiSH7">IDOLiSH7</a></li>
                <li><a href="/category/inazuma-eleven-outer-code" title="Inazuma Eleven: Outer Code">Inazuma Eleven: Outer Code</a></li>
                <li><a href="/category/ito-junji-collection" title="Ito Junji: Collection">Ito Junji: Collection</a></li>
                <li><a href="/category/ito-junji-collection-dub" title="Ito Junji: Collection (Dub)">Ito Junji: Collection (Dub)</a></li>
                <li><a href="/category/jewelpet-attack-chance-" title="Jewelpet: Attack Chance!?">Jewelpet: Attack Chance!?</a></li>
                <li><a href="/category/kaijuu-girls-ultra-kaijuu-gijinka-keikaku-2nd-season" title="Kaijuu Girls: Ultra Kaijuu Gijinka Keikaku 2nd Season">Kaijuu Girls: Ultra Kaijuu Gijinka Keikaku 2nd Season</a></li>
                <li><a href="/category/kamisama-minarai-himitsu-no-cocotama" title="Kamisama Minarai: Himitsu no Cocotama">Kamisama Minarai: Himitsu no Cocotama</a></li>
                <li><a href="/category/karakai-jouzu-no-takagi-san" title="Karakai Jouzu no Takagi-san">Karakai Jouzu no Takagi-san</a></li>
                <li><a href="/category/killing-bites" title="Killing Bites">Killing Bites</a></li>
                <li><a href="/category/kirakiraprecure-a-la-mode" title="Kirakira☆Precure A La Mode">Kirakira☆Precure A La Mode</a></li>
                <li><a href="/category/koi-wa-ameagari-no-you-ni" title="Koi wa Ameagari no You ni">Koi wa Ameagari no You ni</a></li>
                <li><a href="/category/kokkoku" title="Kokkoku">Kokkoku</a></li>
                <li><a href="/category/love-live-sunshine-2nd-season-dub" title="Love Live! Sunshine!! 2nd Season (Dub)">Love Live! Sunshine!! 2nd Season (Dub)</a></li>
                <li><a href="/category/lupin-iii-part-iv-dub" title="Lupin III: Part IV (Dub)">Lupin III: Part IV (Dub)</a></li>
                <li><a href="/category/mahoutsukai-no-yome" title="Mahoutsukai no Yome">Mahoutsukai no Yome</a></li>
                <li><a href="/category/mahoutsukai-no-yome-dub" title="Mahoutsukai no Yome (Dub)">Mahoutsukai no Yome (Dub)</a></li>
                <li><a href="/category/marchen-madchen" title="Märchen Mädchen">Märchen Mädchen</a></li>
                <li><a href="/category/micchiri-neko" title="Micchiri Neko">Micchiri Neko</a></li>
                <li><a href="/category/miira-no-kaikata" title="Miira no Kaikata">Miira no Kaikata</a></li>
                <li><a href="/category/mitsuboshi-colors" title="Mitsuboshi Colors">Mitsuboshi Colors</a></li>
                <li><a href="/category/mobile-suit-gundam-the-origin" title="Mobile Suit Gundam: The Origin">Mobile Suit Gundam: The Origin</a></li>
                <li><a href="/category/monster-hunter-stories-ride-on" title="Monster Hunter Stories: Ride On">Monster Hunter Stories: Ride On</a></li>
                <li><a href="/category/monster-hunter-stories-ride-on-dub" title="Monster Hunter Stories: Ride On (Dub)">Monster Hunter Stories: Ride On (Dub)</a></li>
                <li><a href="/category/monster-musume-no-iru-nichijou-ova" title="Monster Musume no Iru Nichijou OVA">Monster Musume no Iru Nichijou OVA</a></li>
                <li><a href="/category/monster-strike-kieyuku-uchuu-hen" title="Monster Strike: Kieyuku Uchuu-hen">Monster Strike: Kieyuku Uchuu-hen</a></li>
                <li><a href="/category/mori-no-yousei-kinoko-no-musume" title="Mori no Yousei: Kinoko no Musume">Mori no Yousei: Kinoko no Musume</a></li>
                <li><a href="/category/musashino" title="Musashino!">Musashino!</a></li>
                <li><a href="/category/nanatsu-no-bitoku" title="Nanatsu no Bitoku">Nanatsu no Bitoku</a></li>
                <li><a href="/category/nanatsu-no-taizai-imashime-no-fukkatsu" title="Nanatsu no Taizai: Imashime no Fukkatsu">Nanatsu no Taizai: Imashime no Fukkatsu</a></li>
                <li><a href="/category/one-piece" title="One Piece">One Piece</a></li>
                <li><a href="/category/one-piece-dub" title="One Piece (Dub)">One Piece (Dub)</a></li>
                <li><a href="/category/osomatsu-san-2" title="Osomatsu-san 2">Osomatsu-san 2</a></li>
                <li><a href="/category/overlord-ii" title="Overlord II">Overlord II</a></li>
                <li><a href="/category/overlord-ple-ple-pleiades-2" title="Overlord: Ple Ple Pleiades 2">Overlord: Ple Ple Pleiades 2</a></li>
                <li><a href="/category/pikotarou-no-lullaby-lullaby-web" title="Pikotarou no Lullaby Lullaby (Web)">Pikotarou no Lullaby Lullaby (Web)</a></li>
                <li><a href="/category/pingu-in-the-city" title="Pingu in the City">Pingu in the City</a></li>
                <li><a href="/category/pokemon-sun-moon" title="Pokemon Sun & Moon">Pokemon Sun & Moon</a></li>
                <li><a href="/category/poputepipikku" title="Poputepipikku">Poputepipikku</a></li>
                <li><a href="/category/poputepipikku-dub" title="Poputepipikku (Dub)">Poputepipikku (Dub)</a></li>
                <li><a href="/category/princess-principal-picture-drama" title="Princess Principal Picture Drama">Princess Principal Picture Drama</a></li>
                <li><a href="/category/pripara-movie-minna-de-kagayake-kirarinstar-live" title="PriPara Movie: Mi~nna de Kagayake! Kirarin☆Star Live!">PriPara Movie: Mi~nna de Kagayake! Kirarin☆Star Live!</a></li>
                <li><a href="/category/puzzle-dragons-cross" title="Puzzle & Dragons Cross">Puzzle & Dragons Cross</a></li>
                <li><a href="/category/puzzle-dragons-cross-dub" title="Puzzle & Dragons Cross (Dub)">Puzzle & Dragons Cross (Dub)</a></li>
                <li><a href="/category/ramen-daisuki-koizumi-san" title="Ramen Daisuki Koizumi-san">Ramen Daisuki Koizumi-san</a></li>
                <li><a href="/category/relife-kanketsu-hen" title="ReLIFE: Kanketsu-hen">ReLIFE: Kanketsu-hen</a></li>
                <li><a href="/category/rwby-volume-5" title="RWBY Volume 5">RWBY Volume 5</a></li>
                <li><a href="/category/ryuuou-no-oshigoto" title="Ryuuou no Oshigoto!">Ryuuou no Oshigoto!</a></li>
                <li><a href="/category/saiki-kusuo-no-ps-nan-2" title="Saiki Kusuo no Ψ-nan 2">Saiki Kusuo no Ψ-nan 2</a></li>
                <li><a href="/category/sakura-internet" title="Sakura Internet">Sakura Internet</a></li>
                <li><a href="/category/sakura-no-chikai-marronniyell-higashi-no-hichou-shimotsuke-shi-wo-yell" title="Sakura no Chikai: Marronni☆Yell - Higashi no Hichou Shimotsuke-shi wo Yell!">Sakura no Chikai: Marronni☆Yell - Higashi no Hichou Shimotsuke-shi wo Yell!</a></li>
                <li><a href="/category/sanrio-danshi" title="Sanrio Danshi">Sanrio Danshi</a></li>
                <li><a href="/category/sengoku-night-blood" title="Sengoku Night Blood">Sengoku Night Blood</a></li>
                <li><a href="/category/sentai-hero-sukiyaki-force" title="Sentai Hero Sukiyaki Force">Sentai Hero Sukiyaki Force</a></li>
                <li><a href="/category/shinkansen-henkei-robo-shinkalion-the-animation" title="Shinkansen Henkei Robo Shinkalion The Animation">Shinkansen Henkei Robo Shinkalion The Animation</a></li>
                <li><a href="/category/shounen-ashibe-go-go-goma-chan-2" title="Shounen Ashibe: Go! Go! Goma-chan 2">Shounen Ashibe: Go! Go! Goma-chan 2</a></li>
                <li><a href="/category/slow-start" title="Slow Start">Slow Start</a></li>
                <li><a href="/category/sora-yori-mo-tooi-basho" title="Sora yori mo Tooi Basho">Sora yori mo Tooi Basho</a></li>
                <li><a href="/category/takunomi" title="Takunomi.">Takunomi.</a></li>
                <li><a href="/category/the-king-of-fighters-destiny" title="The King of Fighters: Destiny">The King of Fighters: Destiny</a></li>
                <li><a href="/category/time-bokan-gyakushuu-no-san-akunin" title="Time Bokan: Gyakushuu no San Akunin">Time Bokan: Gyakushuu no San Akunin</a></li>
                <li><a href="/category/toji-no-miko" title="Toji no Miko">Toji no Miko</a></li>
                <li><a href="/category/toji-no-miko-dub" title="Toji no Miko (Dub)">Toji no Miko (Dub)</a></li>
                <li><a href="/category/violet-evergarden" title="Violet Evergarden">Violet Evergarden</a></li>
                <li><a href="/category/youkai-watch" title="Youkai Watch ">Youkai Watch </a></li>
                <li><a href="/category/yowamushi-pedal-glory-line" title="Yowamushi Pedal: Glory Line">Yowamushi Pedal: Glory Line</a></li>
                <li><a href="/category/yu-gi-oh-vrains" title="Yu-Gi-Oh! VRAINS">Yu-Gi-Oh! VRAINS</a></li>
                <li><a href="/category/yuru-camp" title="Yuru Camp△">Yuru Camp△</a></li>
                <li><a href="/category/zoku-touken-ranbu-hanamaru" title="Zoku Touken Ranbu: Hanamaru">Zoku Touken Ranbu: Hanamaru</a></li>
                <li><a href="/category/zoku-touken-ranbu-hanamaru-dub" title="Zoku Touken Ranbu: Hanamaru (Dub)">Zoku Touken Ranbu: Hanamaru (Dub)</a></li>
              </ul>
            </nav>
          </div>
        </div>
      </div>

0 个答案:

没有答案