tamalw (owner)

Fork Of

gist: 41922 by lburton A dumb little script to ana...

Revisions

  • c2f9bb firblitz Wed Dec 31 00:21:48 -0800 2008
  • 75846b lburton Tue Dec 30 23:51:22 -0800 2008
  • feb5fa Tue Dec 30 23:50:11 -0800 2008
gist: 41926 Download_button fork
public
Public Clone URL: git://gist.github.com/41926.git
Embed All Files: show embed
Do they really care? #
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/ruby
 
require 'rubygems'
require 'net/http'
require 'hpricot'
 
class Twitter
 
  def initialize(username, password)
    
    @http = Net::HTTP.start('twitter.com')
    @username = username
    @password = password
    
  end
 
  def _get_doc_for_url(url)
    url = URI.parse(url)
    req = Net::HTTP::Get.new(url.request_uri)
    req.basic_auth(@username, @password)
    res = @http.request(req)
    return Hpricot.XML(res.body)
  end
 
  def followers(page=1)
    url = "http://twitter.com/statuses/followers.xml?page=#{page}"
    doc = self._get_doc_for_url(url)
    followers = doc.search("users user").map { |u| u.at("screen_name").inner_text }
    if followers.length == 100
      followers += self.followers(page+1)
    end
    return followers
  end
  
  def friends(page=1)
    url = "http://twitter.com/statuses/friends.xml?page=#{page}"
    doc = self._get_doc_for_url(url)
    friends = doc.search("users user").map { |u| u.at("screen_name").inner_text }
    if friends.length == 100
      friends += self.friends(page+1)
    end
    return friends
  end
  
  def repliers(page=1)
    return [] if page > 5
    url = "http://twitter.com/statuses/replies.xml?page=#{page}"
    doc = self._get_doc_for_url(url)
    repliers = doc.search("statuses status user").map { |u| u.at("screen_name").inner_text }
    if repliers.length == 20
      repliers += self.repliers(page+1)
    end
    return repliers
  end
end
 
f = Twitter.new("your username", "your password")
 
followers = f.followers
friends = f.friends
repliers = f.repliers
 
unreciprocated = friends - followers
groupies = followers - friends
tentative_unrepentant_unreciprocators = unreciprocated - repliers
unreciprocated_but_thinking_of_you = repliers & unreciprocated
 
puts "UNRECIPROCATED"
puts "--------------"
p unreciprocated
 
puts "\n"
 
puts "TENTATIVE UNREPENTANT UNRECIPROCATORS"
puts "-------------------------------------"
p tentative_unrepentant_unreciprocators
 
puts "\n"
 
puts "UNRECIPROCATED BUT THINKING OF YOU"
puts "----------------------------------"
p unreciprocated_but_thinking_of_you
 
puts "\n"
 
puts "GROUPIES"
puts "--------"
p groupies