これが私がスクレイプする必要があるコードのサンプルブロックです:
<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>
このスクリプトは、ページ上のすべてのURLのリストを生成します。
<script>
var allLinks = document.links;
for (var i=0; i<allLinks.length; i++) {
document.write(allLinks[i].href+"<BR/>");
}
</script>
特定のドメインを含むURLのみをリストするようにスクリプトを変更するにはどうすればよいですか。twitter.com/?
これがデモページです:http: //chsweb.me/OucTum