如何在使用li.h3时从链接(href)中提取文本 以下是我的代码:
<div class="lvpic pic img left" iid="263050872757">
<div class="lvpicinner full-width picW">
<div class="triangle"></div>
<div class="urgency"></div>
<a class="img imgWr2" href="http://www.ebay.com/itm/LEGO-31313-Mindstorms-EV3-Robot-Technic-NEW-SEALED-/263050872757?epid=140182845&hash=item3d3f0dc7b5:g:4EIAAOSwLsBZS6bF">
<img class="img" alt="LEGO 31313 Mindstorms EV3 - Robot Technic ***NEW & SEALED***" src="https://i.ebayimg.com/thumbs/images/g/4EIAAOSwLsBZS6bF/s-l225.jpg">
</a>
</div></div>
<h3 class="lvtitle"><a title="Click this link to access LEGO 31313 Mindstorms EV3 - Robot Technic ***NEW & SEALED***" class="vip" href="http://www.ebay.com/itm/LEGO-31313-Mindstorms-EV3-Robot-Technic-NEW-SEALED-/263050872757?epid=140182845&hash=item3d3f0dc7b5:g:4EIAAOSwLsBZS6bF">LEGO 31313 Mindstorms EV3 - Robot Technic ***NEW & SEALED***</a>
</h3>
答案 0 :(得分:0)
不确定我是否正确理解了您的问题。但是如果你想在<a>
标签中抓取href并在<h3>
标签内解析它,你可以做类似的事情。希望有所帮助。
document.querySelector('.lvtitle .vip').href.split("/")
这将是上述查询的结果:
["http:", "", "www.ebay.com", "itm", "LEGO-31313-Mindstorms-EV3-Robot-
Technic-NEW-SEALED-", "263050872757?
epid=140182845&hash=item3d3f0dc7b5:g:4EIAAOSwLsBZS6bF"]