-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweets_per_hour.rb
executable file
·37 lines (30 loc) · 984 Bytes
/
tweets_per_hour.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ruby
#This script was written by Steve Dierker on 27C3 and
#stands under the GPL v3.0.
#http://www.gnu.org/licenses/gpl.html
require 'twitter'
HASHTAG = "27c3"
search = Twitter::Search.new
startid = 20192516867358720
if File.exists?("id.store")
id_store = File.new("id.store","r")
startid = id_store.readline.to_i
end
starttime = Twitter::Search.new.hashtag(HASHTAG).max(startid).fetch.first.created_at
current_page = search.hashtag(HASHTAG).since_id(startid).per_page(100).fetch
if !current_page.empty?
next_id = current_page.first.id
counter = current_page.count
while search.next_page?() do
current_page = search.fetch_next_page
counter += current_page.count
end
quotient = (counter / (Time.now - Time.parse(starttime)))*60*60
id_store = File.new("id.store","w")
id_store.write "#{next_id}"
else
quotient = 0
end
puts "Aktuelle Tweets/h: #{quotient}"
index = File.new("html/index.html", "w")
index.write "#{quotient.truncate}"