douwen5924 2013-02-13 02:32
浏览 133
已采纳

根据URL的末尾使用simple_html_dom获取特定URL

I need to grab a URL using simple_html_dom based on the end of the URL. The URL has no specific class to make it unique. The only thing unique about it is that it ends with a specific set of numbers. I just cannot figure out the proper syntax to grab that specific URL and then print it.

Any help?

EXAMPLE:

<table class="findList">
<tr class="findResult odd"> <td class="primary_photo"> <a href="/title/tt0080487/?ref_=fn_al_tt_1" ><img src="http://ia.media-imdb.com/images/M/MV5BNzk2OTE2NjYxNF5BMl5BanBnXkFtZTYwMjYwNDQ5._V1_SY44_CR0,0,32,44_.jpg" height="44" width="32" /></a> </td>

That is the code for the beginning of the table. That first href is the one I want to grab. The table continues with more links, etc, but that's not relevant to what I want.

  • 写回答

3条回答 默认 最新

  • ds000001 2013-02-15 09:00
    关注

    For the first a with a href ending in 1:

    $dom->find('a[href$="1"]', 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题