Académique Documents
Professionnel Documents
Culture Documents
- CodeProject
In this code, I will show you how to detect who unfriended you on Facebook. It compares your original friend list with your current
friend list, and lists names of all the friends who removed you.
Introduction
Facebook comprises more than 2 billion active users each month in 2018! One of the services of this social network is sending you
notifications about the new friend requests. Despite this service, Facebook will not let you be aware of unfriend events. You can only
realize if someone removes you by checking the number of friends.
In this context, I wrote a Java code with Selenium API that gets all the friend names from your Facebook profile and saves them into
an Excel file. Then you can run this code each time you want, and get a result of all the names of friends who removed you.
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.read.biff.BiffException;
import org.json.JSONException;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
/**
* @author hussein.hazimeh
* 23.03.2019
*
*/
public class UnfriendDetector{
private static String dir = "C:/Users/husseiny.hazimeh/Desktop/chromedriver_win32";
private static WebDriver driver;
private String inputFile;
cc.setInputFile("d:/friend2.xls");
ArrayList<String> oldList = cc.get_old_list();
System.out.println("i am in excel file");
System.out.println(newList.size() + " current friend list : " + newList);
System.out.println(oldList.size() + " old friend list : " + oldList);
oldList.removeAll(newList);
System.out.println("UnFreind_list : " + oldList);
}
driver.get("https://www.facebook.com/");
driver.findElement(By.name("email")).sendKeys("your_facebook_email");
driver.findElement(By.name("pass")).sendKeys("your_facebook_pass");
driver.findElement(By.id("loginbutton")).click();
driver.get("https://www.facebook.com/your_facebook_id/friends?
lst=100002506107371%3A100002506107371%3A1553263520&source_ref=pb_friends_tl");
driver.close();
return friends;
}
if (type == CellType.LABEL) {
friends.add(cell.getContents());
}
https://www.codeproject.com/Articles/1280631/How-To-Detect-Who-Unfriended-You-on-Facebook?display=Print 2/3
25/03/2019 How To Detect Who Unfriended You on Facebook? - CodeProject
if (type == CellType.NUMBER) {
}
}
}
} catch (BiffException e) {
e.printStackTrace();
}
return friends;
}
}
History
23rd March, 2019: Initial version
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile Article Copyright 2019 by Hussein_Hazimeh
Web05 | 2.8.190306.1 | Last Updated 25 Mar 2019 Everything else Copyright © CodeProject, 1999-2019
https://www.codeproject.com/Articles/1280631/How-To-Detect-Who-Unfriended-You-on-Facebook?display=Print 3/3