Created
June 2, 2012 16:18
-
-
Save naoty/2859031 to your computer and use it in GitHub Desktop.
「#minatork01 gist.github.com -rt」で検索した結果からURLを展開・抽出
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@naoty_k https://gist.github.com/2859031 | |
@june29 https://gist.github.com/2856957 | |
@Kirika_K2 https://gist.github.com/2856695 | |
@r7kamura https://gist.github.com/2856841 | |
@sugamasao https://gist.github.com/2856811 | |
@naoty_k http://gist.github.com/2856817 | |
@kei_s https://gist.github.com/2856767 | |
@tdtds https://gist.github.com/2856767 | |
@ymorimo https://gist.github.com/2856767 | |
@nari3 https://gist.github.com/2856773 | |
@ppworks https://gist.github.com/2856772 | |
@netwillnet https://gist.github.com/2856690 | |
@takai https://gist.github.com/2856693 | |
@bash0C7 https://gist.github.com/2856738 | |
@ppworks https://gist.github.com/2856702 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'url_expander' | |
require 'pry' | |
query = 'minatork01+gist.github.com+-rt' | |
Net::HTTP.start('search.twitter.com') do |http| | |
response = http.get('/search.json?q=' + query) | |
json = JSON.parse(response.body) | |
results = json['results'] | |
results.each do |result| | |
user = result['from_user'] | |
tweet = result['text'] | |
url = tweet.slice(/https?:\/\/t\.co\/\w+/) | |
next if url.nil? | |
url = url.gsub(/https/, 'http') | |
expanded_url = UrlExpander::Client.expand(url) | |
puts "@#{user}\t#{expanded_url}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment