Skip to content

Instantly share code, notes, and snippets.

@mia-0032
Created December 26, 2012 03:53
Show Gist options
  • Save mia-0032/4377708 to your computer and use it in GitHub Desktop.
Save mia-0032/4377708 to your computer and use it in GitHub Desktop.
Twitterを特定の単語で検索して、表示するスクリプト。 文中のリンクとハッシュタグ、リプライにはリンクを貼る。 jQuery必要。 今はもうTwitterAPIのバージョン変わってるから動かないかも。
window.onload = function() {
$.getJSON("http://search.twitter.com/search.json?q='hoge'+OR+'foo'&rpp=5&callback=?",
{}, function (data) {
$.each(data.results, function (i,v) {
var tweet = v.text;
tweet = tweet.replace(/(http:\/\/[\x21-\x7e]+)/gi, "<a href='$1'>$1</a>");
tweet = tweet.replace(/#([\x21-\x7e]+)/gi, "<a href=http://twitter.com/#!/search?q=%23$1 target='_blank'>#$1</a>");
tweet = tweet.replace(/@([\x21-\x39\x3b-\x7e]+)/gi, "<a href=http://twitter.com/#!/$1 target='_blank'>@$1</a>:");
$("#tweetList").append(tweet + "<br>");
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment