Created
May 21, 2009 11:52
-
-
Save haqu/115420 to your computer and use it in GitHub Desktop.
follow wefollow
This file contains 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
#!/usr/bin/env ruby | |
# script to extract and follow users from wefollow directory | |
# example: | |
# $ ./wefollow.rb iphonedev | |
# this will extract users from http://wefollow.com/tag/iphonedev | |
# and add them to your 'following' list | |
tag = ARGV[0] || exit | |
# to install chirpy: | |
# $ git clone git://github.com/ashrewdmint/chirpy.git | |
# $ cd chirpy | |
# $ gem build chirpy.gemspec | |
# $ sudo gem install chirpy-x.x.x.gem | |
require 'hpricot' | |
require 'open-uri' | |
require 'chirpy' | |
# you need to provide your twitter's username and password | |
# create config.yaml : | |
# username: <username> | |
# password: <password> | |
config = YAML::load(File.open('config.yaml')) | |
username = config['username'] | |
password = config['password'] | |
puts | |
puts "[*] Parsing WeFollow and following" | |
puts "username: "+username | |
puts "tag: "+tag | |
puts | |
url = "http://wefollow.com/tag/#{tag}" | |
users = [] | |
Hpricot(open(url)).search("div.main-info h3 a").each do |u| | |
users << u.innerHTML | |
end | |
chirpy = Chirpy.new(username,password) | |
friends = [] | |
chirpy.friends.search('user').each do |u| | |
friends << u.at('screen_name').innerHTML | |
end | |
users -= friends | |
users.delete(username) | |
users.uniq! | |
puts "targets" | |
count_added = 0 | |
users.each do |u| | |
chirpy.create_friendship(u) | |
count_added += 1 | |
puts "%-2d %s" % [count_added,u] | |
end | |
puts | |
count_friends = chirpy.friends.search('user').count | |
puts "#{username} following #{count_friends} users (#{count_added} added)" | |
puts | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment