public void PiplApiSearchExecuted(object args) { FacebookLinkModel facebookLinkModel = SelectedFacebookLinkModel; if (SelectedFacebookLinkModel == null || String.IsNullOrEmpty(facebookLinkModel.CurrentCity) || String.IsNullOrEmpty(facebookLinkModel.CurrentCity)) { MessageBox.Show("You must first scrape facebook before doing sub operations"); return; } IsLoading = true; if (facebookLinkModel != null && !String.IsNullOrEmpty(facebookLinkModel.CurrentCity)) { PiplStuff.RetrievePiplData(facebookLinkModel.FirstName, facebookLinkModel.LastName, facebookLinkModel.CurrentCity, facebookLinkModel.CurrentState, (personArray) => { facebookLinkModel.PiplLinks = personArray; IsLoading = false; }); } }
public static List <FacebookLinkModel> GetLinksFromFindFriends(string source) { List <FacebookLinkModel> _facebookUsers = new List <FacebookLinkModel>(); MatchCollection matches = Regex.Matches(source, FacebookRegexConfiguration.GetLinksFromFindFriendsPageRegex); foreach (Match blob in matches) { FacebookLinkModel facebookLinkModel = new FacebookLinkModel(); facebookLinkModel.TargetSource = blob.Value; Match url = Regex.Match(blob.Value, "(?<=href=\").*?(?=\")"); if (url != null) { facebookLinkModel.TargetUrl = url.Value; } Match displayName = Regex.Match(blob.Value, "(?<=/ajax/hovercard/user.php).*?(?=</a)"); if (displayName != null) { Match innerMatch = Regex.Match(displayName.Value, "(?<=\">).*"); facebookLinkModel.DisplayName = innerMatch.Value; if (facebookLinkModel.DisplayName.Contains("<")) { int index = facebookLinkModel.DisplayName.IndexOf("<"); facebookLinkModel.DisplayName = facebookLinkModel.DisplayName.Substring(0, index); } } _facebookUsers.Add(facebookLinkModel); } return(_facebookUsers); }
public async void ExecutedSpouseModifiedSearchVoterDBCommand(object args) { IsLoading = true; FacebookLinkModel facebookLinkModel = SelectedFacebookLinkModel; RunSpouseQuery(facebookLinkModel); }
private async void RunSpouseQuery(FacebookLinkModel facebookLinkModel) { if (!String.IsNullOrEmpty(facebookLinkModel.MarriedTo)) { facebookLinkModel.PossibleSpouseLinks = await DatabaseStuff.RunQuery(facebookLinkModel.SpouseFirstName, facebookLinkModel.SpouseLastName, facebookLinkModel.CurrentCity); } }
public bool CanExecuteModifiedSearchVoterDBCommand(object args) { FacebookLinkModel facebookLinkModel = SelectedFacebookLinkModel; if (facebookLinkModel != null && !String.IsNullOrEmpty(facebookLinkModel.CurrentCity)) { return(!String.IsNullOrEmpty(facebookLinkModel.CurrentCity)); } else { return(false); } }
private void FacebookButton_Click(object sender, RoutedEventArgs e) { List <FacebookLinkModel> _facebookUsers = new List <FacebookLinkModel>(); FacebookButton.Visibility = Visibility.Collapsed; FaceBookBrowser.Visibility = Visibility.Collapsed; FacebookListBox.Visibility = Visibility.Visible; DetailsContainer.Visibility = Visibility.Visible; dynamic document = FaceBookBrowser.Document; var source = document.documentElement.InnerHtml; MatchCollection matches = Regex.Matches(source, "(?<=friendBrowserNameTitle fsl fwb fcb).*?(?=friendBrowserMarginTopMini)"); foreach (Match blob in matches) { FacebookLinkModel facebookLinkModel = new FacebookLinkModel(); facebookLinkModel.TargetSource = blob.Value; Match url = Regex.Match(blob.Value, "(?<=href=\").*?(?=\")"); if (url != null) { facebookLinkModel.TargetUrl = url.Value; } Match displayName = Regex.Match(blob.Value, "(?<=/ajax/hovercard/user.php).*?(?=</a)"); if (displayName != null) { Match innerMatch = Regex.Match(displayName.Value, "(?<=\">).*"); facebookLinkModel.DisplayName = innerMatch.Value; if (facebookLinkModel.DisplayName.Contains("<")) { int index = facebookLinkModel.DisplayName.IndexOf("<"); facebookLinkModel.DisplayName = facebookLinkModel.DisplayName.Substring(0, index); } } _facebookUsers.Add(facebookLinkModel); } this.DataContext = new SearchFacebookViewModel(_facebookUsers); }
public async void SearchVoterDBCommandExecuted(object args) { FacebookLinkModel facebookLinkModel = args as FacebookLinkModel; if (facebookLinkModel == null || String.IsNullOrEmpty(facebookLinkModel.CurrentCity) || String.IsNullOrEmpty(facebookLinkModel.CurrentCity)) { MessageBox.Show("You must first scrape facebook before doing sub operations"); return; } IsLoading = true; SelectedFacebookLinkModel = facebookLinkModel; facebookLinkModel.PossibleLinks = await DatabaseStuff.RunQuery(facebookLinkModel.FirstName, facebookLinkModel.LastName, facebookLinkModel.CurrentCity); RunSpouseQuery(facebookLinkModel); if (facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleLinks.Count > 0 && facebookLinkModel.PossibleSpouseLinks.Count > 0) { bool matched = false; foreach (PersonModel possibleLink in facebookLinkModel.PossibleLinks) { if (matched) { break; } foreach (PersonModel possibleSpouseLink in facebookLinkModel.PossibleSpouseLinks) { if (possibleLink.address == possibleSpouseLink.address) { facebookLinkModel.VoterDBMatch = possibleLink; facebookLinkModel.SouseVoterDBMatch = possibleSpouseLink; matched = true; } } } } IsLoading = false; }
public async void FacebookScrapeExecuted(object args) { // Display the loading screen IsLoading = true; // Get the LinkModel that we're tring to scrape details for FacebookLinkModel facebookLinkModel = args as FacebookLinkModel; SelectedFacebookLinkModel = facebookLinkModel; // Make a call to the target profile url and get the source var source = await ExternalBrowser.CallExternalBrowser(facebookLinkModel.TargetUrl); // Get the real name from the profile string realName = FacebookStuff.GetRealNameFromProfilePage(source); // Get the profile image from the profile facebookLinkModel.ProfileImage = FacebookStuff.GetProfilePhotoFromProfilePage(source); // Get all of the details from the profile page for parsing List <string> details = FacebookStuff.GetIntroFromAuthenticatedProfilePage(source); facebookLinkModel.TargetDetails = details; facebookLinkModel.ParsedDetails = new List <string>(); foreach (string detail in facebookLinkModel.TargetDetails) { string text = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); if (!String.IsNullOrEmpty(text) && !facebookLinkModel.ParsedDetails.Contains(FacebookStuff.GetTextFromSingleDetailAuthenticated(detail))) { facebookLinkModel.ParsedDetails.Add(FacebookStuff.GetTextFromSingleDetailAuthenticated(detail)); } } // If the name contains a space there's more than one name listed if (realName.Contains(' ')) { // If the name has two items in it then set index 0 to first name and index 1 to last name if (realName.Split(' ').Count() == 2) { facebookLinkModel.FirstName = realName.Split(' ')[0]; facebookLinkModel.LastName = realName.Split(' ')[1]; } // Otherwise they list a middle name or initial and set index 0 as first name and index 2 as last name else { facebookLinkModel.FirstName = realName.Split(' ')[0]; facebookLinkModel.LastName = realName.Split(' ')[2]; } } else { facebookLinkModel.FirstName = realName; } if (realName.Contains(',')) { facebookLinkModel.FirstName = realName.Split(',')[1]; facebookLinkModel.LastName = realName.Split(',')[0]; } foreach (string detail in facebookLinkModel.TargetDetails) { // lower the detail so we can identify it easier string lowerDetail = detail.ToLower(); // If the detail contains "lives in" or "current city" then we know this is the current city detail if (lowerDetail.Contains("lives in") || lowerDetail.Contains("current city")) { string cityState = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); if (cityState.Contains(',')) { facebookLinkModel.CurrentCity = cityState.Split(',')[0]; facebookLinkModel.CurrentState = cityState.Split(',')[1]; } else { facebookLinkModel.CurrentCity = cityState; } } // If the detail contains "studied" then it's the college detail if (lowerDetail.Contains("studied")) { facebookLinkModel.College = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); } // If the detail contains "went to" then it's the high school detail if (lowerDetail.Contains("went to")) { facebookLinkModel.HighSchool = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); } // If the detail contains "from" then this detail is for the origin city and state if (lowerDetail.Contains("from")) { string cityState = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); // If there's a comma then split on it and set index 0 as the city and index 1 as the state if (cityState.Contains(',')) { facebookLinkModel.OriginCity = cityState.Split(',')[0]; facebookLinkModel.OriginState = cityState.Split(',')[1]; } else { facebookLinkModel.OriginCity = cityState; } } // If the detail contains mairried to then it will list a spouse if (lowerDetail.Contains("married to")) { string spouseName = FacebookStuff.GetTextFromSingleDetailAuthenticated(detail); facebookLinkModel.MarriedTo = spouseName; // If the name contains a space there's more than one name listed if (spouseName.Contains(' ')) { // If the name has two items in it then set index 0 to first name and index 1 to last name if (spouseName.Split(' ').Count() == 2) { facebookLinkModel.SpouseFirstName = spouseName.Split(' ')[0]; facebookLinkModel.SpouseLastName = spouseName.Split(' ')[1]; } // Otherwise they list a middle name or initial and set index 0 as first name and index 2 as last name else { facebookLinkModel.SpouseFirstName = spouseName.Split(' ')[0]; facebookLinkModel.SpouseLastName = spouseName.Split(' ')[2]; } } else if (spouseName.Contains(',')) { facebookLinkModel.SpouseFirstName = spouseName.Split(',')[1]; facebookLinkModel.SpouseLastName = spouseName.Split(',')[0]; } } // This is the magic string for the little suitcase image next to the job detail text // It's a bad identifier and will likely break if (lowerDetail.Contains("sx_9deefd")) { if (facebookLinkModel.Jobs == null) { facebookLinkModel.Jobs = new List <string>(); } facebookLinkModel.Jobs.Add(FacebookStuff.GetTextFromSingleDetailAuthenticated(detail)); } } IsLoading = false; }
public void ExecutedModifiedSearchVoterDBCommand(object args) { FacebookLinkModel facebookLinkModel = SelectedFacebookLinkModel; SearchVoterDBCommandExecuted(facebookLinkModel); }
public void ConvertToPersonModelExecuted(object args) { PersonModel personModel = new PersonModel(); FacebookLinkModel facebookLinkModel = SelectedFacebookLinkModel; personModel.ImageUrls.Add(facebookLinkModel.ProfileImage); foreach (string job in facebookLinkModel.Jobs) { personModel.Jobs.Add(job); } personModel.Names.Add(facebookLinkModel.DisplayName); personModel.Names.Add(facebookLinkModel.FirstName + " " + facebookLinkModel.LastName); if (facebookLinkModel.PossibleLinks != null && facebookLinkModel.PossibleLinks.Count > 0) { DBLinkModel dblink = facebookLinkModel.PossibleLinks.FirstOrDefault(); personModel.Names.Add(dblink.FormatedName); personModel.Dobs.Add(dblink.dob); personModel.Addresses.Add(dblink.address); } foreach (Person pipLink in facebookLinkModel.PiplLinks) { if (!pipLink.Selected) { continue; } if (pipLink.dob != null) { personModel.Dobs.Add(pipLink.dob.date_range.start); } foreach (Name name in pipLink.names) { personModel.Names.Add(name.display); } foreach (Address address in pipLink.addresses) { personModel.Addresses.Add(address.display); } foreach (Job job in pipLink.jobs) { personModel.Jobs.Add(job.display); } foreach (Phone phone in pipLink.phones) { personModel.PhoneNumbers.Add(phone.display); } foreach (Image image in pipLink.images) { personModel.ImageUrls.Add(image.url); } foreach (Education education in pipLink.educations) { personModel.Schools.Add(education.school + " - " + education.degree); } foreach (string detail in facebookLinkModel.ParsedDetails) { personModel.Details.Add(detail); } } MasterTargetListViewModel.AddTarget(personModel); }