Last active
April 25, 2018 06:35
-
-
Save johndel/29afec4b159203baf7521cd5a50dbb60 to your computer and use it in GitHub Desktop.
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 'mechanize' | |
fb_friends = [] | |
# login | |
agent = Mechanize.new | |
page = agent.get("https://www.facebook.com") | |
next_page = page.form_with(:id => 'login_form') do |form| | |
form.field_with(:id => 'email').value = 'username' | |
form.field_with(:id => 'pass').value = 'password' | |
end.submit | |
i = 0 | |
while true do | |
page2 = agent.get("https://touch.facebook.com/profile.php?v=friends&startindex=#{i}") | |
if page2.search("h3 a").count != 0 | |
page2.search("h3 a").each do |link| | |
fb_friends << link.children.first.text | |
end | |
i = i + page2.search("h3 a").count | |
else | |
break | |
end | |
end | |
fb_friends = fb_friends.uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment