Here is a sample block of code I need to scrape:
<p>This paragraph contains <a href="http://twitter.com/chsweb" data-placement="below" rel="twipsy" target="_blank" data-original-title="Twitter">links to Twitter folks</a>, and <a href="http://twitter.com/blogcycle" data-placement="below" rel="twipsy" target="_blank" data-original-title="Twitter">more links to other Twitter folks</a>, but it also contains <a href="http://www.someOtherWebsiteHere.com">non-Twitter links too</a>. How can I list only the Twitter links below?</p>
This script generates a list of every URL on the page:
<script>
var allLinks = document.links;
for (var i=0; i<allLinks.length; i++) {
document.write(allLinks[i].href+"<BR/>");
}
</script>
How do I modify the script so that it only lists URLs that contain a certain domain, e.g.; twitter.com/?
Here is a demo page: http://chsweb.me/OucTum
document.writewhen you loop DOM node collections, the loop will never get past the first node.