public static UsernameLinkModel ExtractUsernamesFromSource(DBLinkModel target, string source) { //Unauthenticated pattern //string pattern = @"(?<=<a class=""_42ft _4jy0 _4jy3 _517h _51sy"" role=""button"" href=""https:\/\/www.facebook.com\/).*?(?=\/photos"")"; //Authenticated pattern string pattern = FacebookRegexConfiguration.ExtractUserNamesFromProfilePageRegex; string pattern2 = "(?<=class=\"_2ial).*(https:// www.facebook.*)(?=\" data-testid=\"serp_result)"; List <LinkModel> usernames = new List <LinkModel>(); MatchCollection matches = Regex.Matches(source, pattern); if (matches.Count == 0) { matches = Regex.Matches(source, pattern2); } foreach (Match m in matches) { usernames.Add(new LinkModel() { ProfileLink = m.Value, ConfidenceScore = 0 }); } UsernameLinkModel linkModel = new UsernameLinkModel() { id = target.Id, name = target.firstname + " " + target.lastname, usernames = usernames }; Console.WriteLine("Links Made: " + usernames.Count); return(linkModel); }
public static void PrintTargetLink(UsernameLinkModel targetLink) { var localTargetLink = targetLink; //Console.WriteLine(""); //Console.WriteLine(targetLink.name); foreach(LinkModel link in localTargetLink.usernames) { //Console.WriteLine(string.Format("Username: {0} Confidence: {1}", link.ProfileLink, link.ConfidenceScore)); Console.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"",targetLink.id, targetLink.name, link.ProfileLink,link.ConfidenceScore); } }
public static UsernameLinkModel GetUsernameLinkModel(Object datacontext, Guid id) { UsernameLinkModel ret = null; SearchVoterDatabaseViewModel vm = datacontext as SearchVoterDatabaseViewModel; if (vm != null) { ret = vm.TargetLinks.Where(t => t.id == id).FirstOrDefault(); } return(ret); }
private void ProfileExpanderButton_Expanded(object sender, RoutedEventArgs e) { var listBoxItem = GetParent <ListBoxItem>((DependencyObject)sender) as ListBoxItem; if (listBoxItem != null) { LinkModel linkModel = listBoxItem.DataContext as LinkModel; if (linkModel != null) { UsernameLinkModel user = SearchVoterDatabaseViewModel.GetUsernameLinkModel(this.DataContext, linkModel.UserModelLinkId); Expander expander = sender as Expander; if (expander != null) { ListBox innerListbox = expander.Content as ListBox; innerListbox.ItemsSource = user.usernames; } } } }