title: How to scrape links from a webpage using javascript?
body: <p>I'm looking to scrape the links of post shown on facebook feed. I noticed that post link has two things in common it has <a href="https://www.facebook.com/username/posts/1234567890" rel="nofollow noreferrer">https://www.facebook.com/username/posts/1234567890</a></p>
  <p><a href="https://www.facebook.com/" rel="nofollow noreferrer">https://www.facebook.com/</a> and /posts/ is always there.</p>
  <p>I used this code to get all links on the page but I don't know how to only grab links with</p>
  <p><a href="https://www.facebook.com/" rel="nofollow noreferrer">https://www.facebook.com/</a> and /posts/ in this.</p>
  <pre><code>var links = document.querySelectorAll(&quot;a[href^='https://www.facebook.com']&quot;);
  
  for(var i = 0; i&lt; links.length; i++){
    console.log(links[i].href);
  }
  </code></pre>
  <p>I tried regex and this is what I found after learning regex for this url pattern</p>
  <p>^(https://www.|http://)[a-zA-Z0-9!_$]+.[a-zA-Z]+/[a-zA-Z0-9]+/posts/[0-9]+$</p>
  <p>but I don't know how to use this to get the result.</p>
  <p>can anyone please help me with this?</p>