Advertisement
Guest User

Untitled

a guest
Mar 15th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.89 KB | None | 0 0
  1. HtmlElement company_name = null;
  2. HtmlElement adress = null;
  3. HtmlElementCollection phones = null;
  4. HtmlElement website = null;
  5. HtmlElement email = null;
  6. HtmlElement mid_rating = null;
  7. string str_phones = string.Empty;
  8.  
  9.  
  10. company_name = instance.ActiveTab.FindElementByXPath("//h1[@class = '_1r7sat2']/span[@class = '_oqoid']", 0);
  11. adress = instance.ActiveTab.FindElementByXPath("//span[@class = '_14quei']/descendant::a[@class = '_84s065h']", 0);
  12. website = instance.ActiveTab.FindElementByXPath("//div[@class='_49kxlr']/span/div/a[@class = '_13ptbeu']", 0);
  13. email = instance.ActiveTab.FindElementByXPath("//div[@class = '_49kxlr']/descendant::a[contains(text(), '@')]", 0);
  14. mid_rating = instance.ActiveTab.FindElementByXPath("//span[@class = '_1n8h0vx']", 0);
  15. phones = instance.ActiveTab.FindElementsByXPath("//div[@class = '_b0ke8']");
  16.  
  17. if (phones.Count<=1) {
  18.     str_phones = phones.GetByNumber(0).InnerText;
  19.    
  20. }
  21. else {
  22. foreach (var phone in phones) {
  23.      str_phones = str_phones + phone.InnerText + "; " + Environment.NewLine;
  24.     }  
  25.  
  26. }
  27.  
  28. project.Variables["cur_company_name"].Value = company_name.InnerText;
  29. project.Variables["cur_company_adress"].Value = adress.InnerText;
  30. project.Variables["cur_company_website"].Value = website.InnerText;
  31. project.Variables["cur_company_email"].Value = email.InnerText;
  32. project.Variables["cur_company_mid_rating"].Value = mid_rating.InnerText;
  33. project.Variables["cur_company_phones"].Value = str_phones;
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик 2-й Кубик
  42.  
  43. string str_for_excel = string.Empty;
  44. string query_fields = project.Variables["query_fields"].Value;
  45. string name = "Название";
  46. string adress = "адрес";
  47. string phones = "телефоны";
  48. string website = "сайт";
  49. string email = "email";
  50. string social = "социальные сети";   
  51. string mid_rating = "средняя оценка";
  52. string advertisement_link = "ссылка объявления";
  53. string str_all_socials = string.Empty;
  54.  
  55. //Проверяем какие поля ввел пользователь во входящих настройках
  56. if(query_fields.Contains(name)) {
  57.     str_for_excel = "{-Variable.cur_company_name-}";
  58. }
  59.  
  60. if(query_fields.Contains(adress)) {
  61.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_company_adress-}";
  62.    
  63. }
  64.  
  65. if(query_fields.Contains(phones)) {
  66.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_company_phones-}";
  67.    
  68. }
  69.  
  70. if(query_fields.Contains(website)) {
  71.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_company_website-}";
  72. }
  73.  
  74. if(query_fields.Contains(email)) {
  75.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_company_email-}";
  76. }
  77.  
  78. if(query_fields.Contains(social)) {
  79.     //проверяем есть ли вк
  80.     if(project.Variables["cur_company_vk"].Value!="") {
  81.         str_all_socials = project.Variables["cur_company_vk"].Value;
  82.     }
  83.     //проверяем есть ли фб
  84.     if(project.Variables["cur_company_facebook"].Value!="") {
  85.         str_all_socials = str_all_socials + "; " + project.Variables["cur_company_facebook"].Value;
  86.     }
  87.     //проверяем есть ли инстаграм
  88.     if(project.Variables["cur_company_instagramm"].Value!=""){
  89.         str_all_socials = str_all_socials + "; " + project.Variables["cur_company_instagramm"].Value;
  90.     }
  91.     //формируем строку с соц. сетями, // добавить перенос строки 
  92.     str_for_excel = str_for_excel + str_all_socials;
  93. }
  94.  
  95. if(query_fields.Contains(mid_rating)) {
  96.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_company_mid_rating-}";
  97. }
  98.  
  99. if(query_fields.Contains(advertisement_link)) {
  100.     str_for_excel = str_for_excel + "{-String.Tab-}{-Variable.cur_link-}";
  101. }
  102.  
  103. project.Variables["str_for_excel"].Value = str_for_excel;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement