简体   繁体   中英

Getting the Href from a collection of links

使用基本的javascript,我可以找到所有感兴趣的a_hrefs。如何将对象列表转换为URL字符串列表?

document.querySelectorAll("a[href^='https://aaaa/']")

You can use Array.from , which takes an array-like object, and whose second parameter is an (optional) mapper function:

const urls = Array.from(
  document.querySelectorAll("a[href^='https://aaaa/']"),
  a => a.href
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM