Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using OpenQA.Selenium.Chrome; //using OpenQA.Selenium.Firefox; using OpenQA.Selenium; using OpenQA.Selenium.Support.UI; using System.Drawing; using System.Drawing.Imaging; using System.Net; namespace Facebook_Monitoring_System { class Program { static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; //Get User Input //Console.WriteLine("------------- Enter Your Facebook User Name or Email or Phone -------------"); //String FbUsername = Console.ReadLine(); //Console.WriteLine("------------- Enter Your Facebook Password -------------"); //String FbPassword = Console.ReadLine(); //Console.SetCursorPosition(0, Console.CursorTop - 1); //ClearCurrentConsoleLine(); Console.WriteLine("------------- Enter Desired Username to get Information -------------"); String DesiredFbUser = Console.ReadLine(); //Temp user String FbUsername = "dev.dnj"; String FbPassword = "xxxxxxxxxx"; //Desired user to get Information String DesiredUserURL = String.Format("https://mbasic.facebook.com/{0}?v=timeline", DesiredFbUser); //var chromeOptions = new ChromeOptions(); //chromeOptions.AddArguments(new List<string>() { "headless" }); //var driver = new ChromeDriver(chromeOptions); var chrome_options = new ChromeOptions(); chrome_options.AddArgument("--disable-notifications"); // chrome_options.addargument("headless"); var driver = new ChromeDriver(chrome_options); // var driver = new FirefoxDriver(); // Go to google driver.Navigate().GoToUrl("https://mbasic.facebook.com/"); //IWebElement query = driver.FindElement(By.Name("q")); // query.SendKeys("Rafusoft"); /******************* * Login Page ********************/ //Selectors //Login if (IsElementPresent(driver, By.CssSelector("input[name=\"email\"]")) && IsElementPresent(driver, By.CssSelector("input[name=\"pass\"]")) && IsElementPresent(driver, By.CssSelector("input[value=\"Log In\"]"))) { var EmailInput = driver.FindElement(By.CssSelector("input[name=\"email\"]")); var PassInput = driver.FindElement(By.CssSelector("input[name=\"pass\"]")); var LoginButton = driver.FindElement(By.CssSelector("input[value=\"Log In\"]")); //Perform Input action and submit login EmailInput.SendKeys(FbUsername); // driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); PassInput.SendKeys(FbPassword); //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); LoginButton.Click(); // driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); if (IsElementPresent(driver, By.CssSelector("a[href^=\"/login/save-device\"]"))) { var NotNowLink = driver.FindElement(By.CssSelector("a[href^=\"/login/save-device\"]")); NotNowLink.Click(); } /************************* * Desired User Profile ***************************/ // Go to desired user profile driver.Navigate().GoToUrl(DesiredUserURL); StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\PostData.txt", true); IList<IWebElement> all = driver.FindElements(By.CssSelector("div[role=\"article\"]")); String[] allText = new String[all.Count]; int i = 0; foreach (IWebElement element in all) { allText[i++] = element.Text; /** Crawling Time **/ sw.WriteLine(String.Format("Crawling Time: {0}", DateTime.Now.ToString())); /** Crawling Time End **/ /** Post ID**/ String DataFtAttrValue = element.GetAttribute("data-ft"); Console.WriteLine(String.Format("Data FT Value: {0}", DataFtAttrValue)); String[] tokens = DataFtAttrValue.Split(','); tokens = tokens[1].Split(':'); String PostId = tokens[1].Replace('"', ' ').Trim(); Console.WriteLine(String.Format("Post Id: {0}", PostId)); sw.WriteLine(String.Format("Post ID: {0}", PostId)); /** Post ID End**/ //Posted By if (IsElementPresent(element, By.CssSelector("div div:nth-child(1) h3 strong a"))) { String PosterName = element.FindElement(By.CssSelector("div div:nth-child(1) h3 strong a")).Text; // String PostLikeCount = element.FindElement(By.XPath(".//*/a[1]")).Text; //Console.WriteLine(element.Text); sw.WriteLine(String.Format("Posted by: {0}\n", PosterName)); // sw.WriteLine(String.Format("Post Like Count: {0}\n\n", PostLikeCount)); } //Post Content if (IsElementPresent(element, By.CssSelector("div div:nth-child(2)"))) { String PostContent = element.FindElement(By.CssSelector("div div:nth-child(2)")).Text; sw.WriteLine(String.Format("Post Content: {0}\n", PostContent)); } // Post Time if (IsElementPresent(element, By.CssSelector("div:nth-child(2) div:nth-child(1) abbr"))) { String PostedTime = element.FindElement(By.CssSelector("div:nth-child(2) div:nth-child(1) abbr")).Text; sw.WriteLine(String.Format("Posted Time: {0}\n", PostedTime)); } // Post Privary if (IsElementPresent(element, By.CssSelector("div:nth-child(2) div:nth-child(1) span span span"))) { String PostPrivacy = element.FindElement(By.CssSelector("div:nth-child(2) div:nth-child(1) span span span")).Text; sw.WriteLine(String.Format("Post Privacy: {0}\n\n", PostPrivacy)); } } sw.Flush(); sw.Close(); /** StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\PostData.txt",true); IReadOnlyCollection<IWebElement> FbPosts = driver.FindElements(By.CssSelector("div[role=\"article\"]")); for (int i = 0; i < FbPosts.Count; i++) { var PostInfo = FbPosts.ElementAt(i); String Poster = PostInfo.FindElement(By.XPath("//div[1]/div[1]/table/tbody/tr/td[2]/div/h3/strong/a")).Text; String PostContent = PostInfo.FindElement(By.XPath("//div[2]/div[2]/span/p")).GetAttribute("innerHTML"); ; Console.WriteLine(String.Format("Posted By: {0}\n", Poster)); sw.WriteLine(String.Format("Posted By: {0}\n", Poster)); Console.WriteLine(String.Format("Post Content: {0}\n", PostContent)); sw.WriteLine(String.Format("Post Content: {0}\n", PostContent)); Console.WriteLine("\n\n\n"); } sw.Flush(); sw.Close(); **/ /** try { driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); driver.FindElement(By.XPath("//a[contains(text(),'Show more')]")).Click(); } catch (Exception Ex) { Console.WriteLine(Ex.Message); } **/ int numberOfElements = driver.FindElements(By.CssSelector("div[role=\"article\"]")).Count; Console.WriteLine(String.Format("Total Facebook Post: {0}", numberOfElements)); ////Log Out //try{ // WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3)); // for (int i = 1; i < 6; i++) // { // By locator = By.CssSelector("a[href^=\"/logout.php\"]"); // IWebElement element = driver.FindElement(locator); // element.Click(); // wait.Until(ExpectedConditions.StalenessOf(element)); // wait.Until(ExpectedConditions.ElementToBeClickable(locator)); // } // //var LogOut = driver.FindElement(By.CssSelector("a[href^=\"/logout.php\"]")); // //LogOut.Click(); //} //catch (Exception Ex) //{ // Console.WriteLine(Ex.Message); //} // WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(100)); // time out after 5 seconds // Console.WriteLine(String.Format("Page title is: {0}",driver.)); driver.Close(); driver.Quit(); } else { Console.WriteLine("Error: Unable to login. Problem with page loading..."); driver.Close(); driver.Quit(); } Console.ReadKey(); } private static bool IsElementPresent(IWebElement Element, By by) { try { Element.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private static bool IsElementPresent(ChromeDriver Driver, By by) { try { Driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } /**** Helper Functions ****/ private static void ClearCurrentConsoleLine() { int currentLineCursor = Console.CursorTop; Console.SetCursorPosition(0, Console.CursorTop); Console.Write(new string(' ', Console.WindowWidth)); Console.SetCursorPosition(0, currentLineCursor); } private void GetAndSaveImage(ChromeDriver driver, By ImageSelector) { ITakesScreenshot ssdriver = driver as ITakesScreenshot; Screenshot screenshot = ssdriver.GetScreenshot(); Screenshot tempImage = screenshot; tempImage.SaveAsFile(@"full.png", ScreenshotImageFormat.Png); //replace with the XPath of the image element IWebElement my_image = driver.FindElement(ImageSelector); Point point = my_image.Location; int width = my_image.Size.Width; int height = my_image.Size.Height; Rectangle section = new Rectangle(point, new Size(width, height)); Bitmap source = new Bitmap(@"full.png"); Bitmap final_image = CropImage(source, section); final_image.Save(@"image.jpg"); } private Bitmap CropImage(Bitmap source, Rectangle section) { Bitmap bmp = new Bitmap(section.Width, section.Height); Graphics g = Graphics.FromImage(bmp); g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel); return bmp; } private bool ImageDownload(String ImageSource) { Uri uri = new Uri(ImageSource); if (true) { string filename = System.IO.Path.GetFileName(uri.LocalPath); WebClient wb = new WebClient(); wb.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.33 Safari/537.36"); try { wb.DownloadFile(ImageSource, @"fbphoto\" + filename); return true; } catch (Exception Ex) { Console.WriteLine(Ex.Message); return false; } } return false; } } }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
📌 VIP MONEY METHOD 📌 ✅⭐
JavaScript | 49 sec ago | 0.67 KB
💎💎 EARN 7,500$ IN LESS THAN 10 MINUTES OF WOR...
JavaScript | 1 min ago | 0.67 KB
⭐⭐ Crypto Swap Glitch ✅ Easy money ⭐⭐
JavaScript | 3 min ago | 0.67 KB
⭐⭐ Free Crypto Method ⭐⭐ ✅
JavaScript | 5 min ago | 0.67 KB
💎💎💎 HOW TO EARN $5,000 A WEEK [GUIDE] 💎📌 QUIC...
JavaScript | 5 min ago | 0.67 KB
✅✅✅ VIP MONEY GUIDE
JavaScript | 7 min ago | 0.67 KB
🚨🚨🚨 INSTANT $370 PROMOTION
JavaScript | 10 min ago | 0.67 KB
💎💎💎 HOW TO EARN $5,000 A WEEK [GUIDE] 💎 📌📌
JavaScript | 11 min ago | 0.67 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!