private void GetProfileInfo(RemoteWebDriver driver, string path) { var profileInfoPrefix = "ProfileInfo.txt"; var fieldsDiv = driver.FindElementsByClassName("profile_info_row"); var fields = new Dictionary <string, object>(); fields.Add("ProfileID_s", GetProfileId(driver)); fields.Add("Name_s", GetProfileFullName(driver)); if (IsMoreProfileInfoExists(driver)) { ClickOnShowMoreProfileInfo(driver); } foreach (var fieldDiv in fieldsDiv) { var key = fieldDiv.FindElement(By.ClassName("label")).Text.Replace(":", ""); var value = fieldDiv.FindElement(By.ClassName("labeled")).Text; if (fields.ContainsKey(key)) { if (!(fields[key] is List <string>)) { fields[key] = new List <string> { fields[key] as string }; } ((List <string>)fields[key]).Add(value); } else { fields.Add(key, value); } } SerDeUtils.SerializeToJsonFile(fields, Path.Combine(path, profileInfoPrefix)); }
public Dictionary <string, List <string> > Search(RemoteWebDriver driver) { var allOutputResults = new Dictionary <string, List <string> >(); var vkSearchLinks = SerDeUtils.DeserializeJsonFile <Dictionary <string, string> >(LinksInputPath); foreach (var vkSearchKey in vkSearchLinks.Keys) { var results = GetAllSearchResults(driver, vkSearchLinks[vkSearchKey]); allOutputResults.Add(vkSearchKey, results.Select(user => user.GetAttribute("href")).ToList()); } SerDeUtils.SerializeToJsonFile(allOutputResults, ResultsOutputPath); return(allOutputResults); }
private static void Main(string[] args) { RemoteWebDriver driver = new ChromeDriver(); //VkConnector var vkConnector = new VkConnector(); if (!vkConnector.Connect(driver)) { System.Console.WriteLine("Can't Connect to VK"); return; } //VkSearchResultsScanner var vkSearchScanner = new VkSearchResultsScanner(); Dictionary <string, List <string> > searchResults; if (!VkConfigs.GetConfig().ProfileScanner.LoadFromSavedResults) { searchResults = vkSearchScanner.Search(driver); } else { try { searchResults = SerDeUtils.DeserializeJsonFile <Dictionary <string, List <string> > >( VkSearchResultsScanner.ResultsOutputPath); } catch (Exception e) { Console.WriteLine("Can't load results from file. " + e); return; } } //VkProfileScanner var vkProfileScanner = new VkUserProfileScanner(); vkProfileScanner.Scan(driver, searchResults); }