Last active
April 25, 2018 06:35
-
-
Save johndel/29afec4b159203baf7521cd5a50dbb60 to your computer and use it in GitHub Desktop.
Revisions
-
johndel revised this gist
Aug 5, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ require 'mechanize' fb_friends = [] # login agent = Mechanize.new page = agent.get("https://www.facebook.com") -
johndel created this gist
Aug 5, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ require 'mechanize' # 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