public static void GetObj(string put, ProgressCallBack incCallBack, ProgressMax maximum, int sdelano) { HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("https://www.klenmarket.ru/shop/"); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse(); StreamReader streamReader = new StreamReader(response1.GetResponseStream()); string result = streamReader.ReadToEnd(); result = Regex.Match(result, "(?<=<i>По категориям</i>)[\\w\\W]*?(?=<b>Услуги</b>)").Value; string lichnee = Regex.Match(result, "(?<=<i>По типам предприятий</i>)[\\w\\W]*?(?=<b>Посуда и столовые приборы</b>)").Value; result = result.Replace(lichnee, ""); Regex regex = new Regex("(?<=a href=\")[\\w\\W]*?(?=\">)"); int k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] allkatalog = new string[k]; int i = 0; foreach (Match match in regex.Matches(result)) { allkatalog[i] = match.Value; i++; } maximum?.Invoke(allkatalog.Length); for (i = sdelano; i < allkatalog.Length; i++) { incCallBack?.Invoke(); request1 = (HttpWebRequest)WebRequest.Create("https://www.klenmarket.ru" + allkatalog[i]); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); if (result.Contains("class=\"shop-eq-list__cats-item")) { regex = new Regex("(?<=list__cats-item\" href=\").*?(?=\">)"); k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] allgrupp = new string[k]; k = 0; foreach (Match match in regex.Matches(result)) { allgrupp[k] = match.Value; k++; } for (k = 0; k < allgrupp.Length; k++) { try { for (int page = 1; ; page++) { request1 = (HttpWebRequest)WebRequest.Create("https://www.klenmarket.ru" + allgrupp[k] + "page-" + page); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); regex = new Regex("(?<=<a href=\"/shop).*?(?=\">\\s*<img)"); int kolobj = 0, c = 0; foreach (Match match in regex.Matches(result)) { kolobj++; } string[] allobj = new string[kolobj]; foreach (Match match in regex.Matches(result)) { allobj[c] = match.Value; c++; } for (int z = 0; z < allobj.Length; z++) { parsobj(put, allobj[z], k, page, z); } } } catch (WebException) { continue; } } } else { try { for (int page = 1; ; page++) { request1 = (HttpWebRequest)WebRequest.Create("https://www.klenmarket.ru" + allkatalog[i] + "page-" + page); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); regex = new Regex("(?<=<a href=\"/shop).*?(?=\">\\s*<img)"); int kolobj = 0, c = 0; foreach (Match match in regex.Matches(result)) { kolobj++; } string[] allobj = new string[kolobj]; foreach (Match match in regex.Matches(result)) { allobj[c] = match.Value; c++; } for (int z = 0; z < allobj.Length; z++) { parsobj(put, allobj[z], k, page, z); } } } catch (WebException) { continue; } } } }
public static void GetObj(string put, ProgressCallBack incCallBack, ProgressMax maximum, int sdelano, string prox, int stroka) { ExcelStr = stroka; string result2 = ""; int inet = 0; int i = 0; int proxchet1 = 0; int objectchet = 0; string putimag = "", putinst = ""; int allstr = 2, str = 1; StreamReader objReader1 = new StreamReader(prox); string sLine1 = ""; ArrayList proxy = new ArrayList(); while (sLine1 != null) { sLine1 = objReader1.ReadLine(); if (sLine1 != null) { proxy.Add(sLine1); } } objReader1.Close(); CookieContainer cookies = new CookieContainer(); for (int first = 0; first < proxy.Count; first++) { try { HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create("http://www.rp.ru/shop/?set_filter=Y&query=&q=&manufacturer=0&type=0&count=100&XML_ID=§ion=0&sort=0&show_type=2&instore=0&PAGEN_1=" + str); request2.CookieContainer = cookies; request2.Proxy = new WebProxy(proxy[first].ToString()); request2.Headers["Upgrade-Insecure-Requests"] = "1"; request2.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse(); StreamReader streamReader2 = new StreamReader(response2.GetResponseStream()); result2 = streamReader2.ReadToEnd(); break; } catch (WebException) { continue; } } Regex regex = new Regex("(?<=PAGEN_1=).*(?=\">...</a>)"); Match match1 = regex.Match(result2); while (match1.Success) { allstr = Int32.Parse(match1.Value); match1 = match1.NextMatch(); } maximum?.Invoke(allstr); for (str = sdelano + 1; str < allstr; str++) { if (inet > 400) { break; } for (int proxchet = proxchet1; proxchet < proxy.Count; proxchet++) { try { HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("http://www.rp.ru/shop/?set_filter=Y&query=&q=&manufacturer=0&type=0&count=100&XML_ID=§ion=0&sort=0&show_type=2&instore=0&PAGEN_1=" + str); request1.CookieContainer = cookies; request1.Proxy = new WebProxy(proxy[proxchet].ToString()); request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse(); StreamReader streamReader = new StreamReader(response1.GetResponseStream()); string result = streamReader.ReadToEnd(); regex = new Regex("(?<=<td><a href=\").*(?=\" >)"); int k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] obiekt = new string[k]; regex = new Regex("(?<=<td><a href=\").*(?=\" >)"); i = 0; foreach (Match match in regex.Matches(result)) { obiekt[i] = match.Value; i++; } if (i == 0) { proxchet1++; continue; } for (i = objectchet; i < obiekt.Length; i++) { string allanalogi = ""; string allzapchasti = ""; string allsoptov = ""; string silkaobj = "http://www.rp.ru" + obiekt[i]; request1 = (HttpWebRequest)WebRequest.Create(silkaobj); request1.CookieContainer = cookies; request1.Proxy = new WebProxy(proxy[proxchet].ToString()); request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); string name = Regex.Match(result, "(?<=<title>).*(?=</title>)").Value; string artikul = Regex.Match(result, "(?<=/images/).*(?=_o.jpg\" rel)").Value; if (artikul == "") { artikul = Regex.Match(silkaobj, "(?<=\\d/).*?(?=/)").Value; } string cena = Regex.Match(result, "(?<=<br /> ).*(?=<br/>)").Value; string nalichie = Regex.Match(result, "(?<=\\s).*?(?=</b></span>)").Value; nalichie = nalichie.Replace(" ", ""); string opisanie = Regex.Match(result, "(?<=товара</b>)[\\w\\W]*?(?=<a href=)").Value; if (opisanie == "") { opisanie = Regex.Match(result, "(?<=Описание</b></span>)[\\w\\W]*?(?=<img)").Value; if (opisanie == "") { opisanie = Regex.Match(result, "(?<=justify\">)[\\w\\W]*?(?=<iframe)").Value; if (opisanie == "") { opisanie = Regex.Match(result, "(?<=tooltip\\(\\);)[\\w\\W]*?(?=<span class=\"techlabel\")").Value; if (opisanie == "") { opisanie = Regex.Match(result, "(?<=text-align: justify;\">)[\\w\\W]*?(?=<p style=)").Value; } } } } opisanie = opisanie.Replace(">", " ").Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("</b>", "").Replace(" ", "").Replace("<span style=\"color:#ff0000;\"", "").Replace("<b>", "").Replace("</span", "").Replace("</font>", "").Replace("</div>", "").Replace("<br />", "").Replace("});", "").Replace(" ", "").Replace("—", ""); /*while (opisanie.Contains("<")) * { * opisanie = opisanie.Remove(opisanie.IndexOf("<"), opisanie.IndexOf(">", opisanie.IndexOf("<")) - opisanie.IndexOf("<")); * }*/ opisanie = Regex.Replace(opisanie, "<.*?>", string.Empty); string kategor = Regex.Match(result, "(?<=<a href=\"/shop/\\?set_filter=Y&level1=).*?(?=&level2=)").Value; string gruppa = Regex.Match(result, "(?<=<a href=\"/shop/\\?set_filter=Y&level1=" + kategor + "&level2=).*?(?=&level3=)").Value; string image = Regex.Match(result, "(?<=<a href=\").*?(?=.jpg)").Value; string soptovari = Regex.Match(result, "(?<=techlabel\">Сопутствующие товары:)[\\w\\W]*?(?=\"techlabel\">)").Value; if (soptovari == "") { soptovari = Regex.Match(result, "(?<=techlabel\">Сопутствующие товары:)[\\w\\W]*?(?=</table>)").Value; } regex = new Regex("(?<=\\d/).*?(?=/\">)"); foreach (Match match in regex.Matches(soptovari)) { allsoptov = String.Concat(allsoptov, match.Value + ","); } string proizvoditel = Regex.Match(result, "(?<=/'>).*?(?=</A>)").Value; string strana = Regex.Match(result, "(?<=Страна:</div></td>)[\\w\\W]*?(?=</td>)").Value; strana = strana.Replace(" ", "").Replace("<td>", "").Replace("\n", "").Replace("\t", ""); string gabarit = Regex.Match(result, "(?<=\\(нетто\\):</div></td>)[\\w\\W]*?(?=</td>)").Value; gabarit = gabarit.Replace(" ", "").Replace("<td>", "").Replace("\n", "").Replace("\t", ""); string ves = Regex.Match(result, "(?<=\\(брутто\\):</div></td>)[\\w\\W]*?(?=</td>)").Value; ves = ves.Replace(" ", "").Replace("<td>", "").Replace("\n", "").Replace("\t", ""); string moch = Regex.Match(result, "(?<=ость:</div></td>)[\\w\\W]*?(?=</td>)").Value; moch = moch.Replace(" ", "").Replace("<td>", "").Replace("\n", "").Replace("\t", ""); string napr = Regex.Match(result, "(?<=жение:</div></td>)[\\w\\W]*?(?=</td>)").Value; napr = napr.Replace(" ", "").Replace("<td>", "").Replace("\n", "").Replace("\t", ""); string dopopisanie = Regex.Match(result, "(?<=Описание:</div></td>)[\\w\\W]*?(?=</td>)").Value; if (dopopisanie == "") { dopopisanie = Regex.Match(result, "(?<=Описание:</div>)[\\w\\W]*?(?=</tr>)").Value; } dopopisanie = dopopisanie.Replace("<td>", "").Replace("\n", "").Replace("\t", "").Replace(" ", "").Replace("(", "").Replace(")", ""); string osnxar = Regex.Match(result, "()").Value; string zapchasti = Regex.Match(result, "(?<=\"techlabel\">Запчасти и комплектующие:)[\\w\\W]*?(?=</table>)").Value; if (zapchasti == "") { zapchasti = Regex.Match(result, "(?<=\"techlabel\">Этот товар Запчасть и комплектующие для:)[\\w\\W]*?(?=</table>)").Value; } regex = new Regex("(?<=\\d/).*?(?=/\">)"); foreach (Match match in regex.Matches(zapchasti)) { allzapchasti = String.Concat(allzapchasti, match.Value + ","); } string allsopdlya = ""; string sopdlya = Regex.Match(result, "(?<=Этот товар сопутствующий для:)[\\w\\W]*?(?=</table>)").Value; regex = new Regex("(?<=\\d/).*?(?=/\">)"); foreach (Match match in regex.Matches(sopdlya)) { allsopdlya = String.Concat(allsopdlya, match.Value + ","); } string instruction = Regex.Match(result, "(?<=href=\").*?(?=_inst.pdf)").Value; string analogi = Regex.Match(result, "(?<=\"techlabel\">Этот товар Аналог)[\\w\\W]*?(?=</table>)").Value; if (analogi == "") { analogi = Regex.Match(result, "(?<=\"techlabel\">Аналоги:)[\\w\\W]*?(?=</table>)").Value; } regex = new Regex("(?<=\\d/).*?(?=/\">)"); foreach (Match match in regex.Matches(analogi)) { allanalogi = String.Concat(allanalogi, match.Value + ","); } DirectoryInfo dirInfo = new DirectoryInfo(put + "\\" + kategor + "\\" + gruppa + "\\"); if (!dirInfo.Exists) { dirInfo.Create(); } if (instruction != "") { request1 = (HttpWebRequest)WebRequest.Create("http://www.rp.ru" + instruction + "_inst.pdf"); request1.CookieContainer = cookies; request1.Proxy = new WebProxy(proxy[proxchet].ToString()); request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); putinst = put + "\\" + kategor + "\\" + gruppa + "\\" + str + i + ".pdf"; using (var inst = File.OpenWrite(putinst)) { response1.GetResponseStream().CopyTo(inst); } } if (image != "") { request1 = (HttpWebRequest)WebRequest.Create("http://www.rp.ru" + image + ".jpg"); request1.CookieContainer = cookies; request1.Proxy = new WebProxy(proxy[proxchet].ToString()); request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); putimag = put + "\\" + kategor + "\\" + gruppa + "\\" + str + i + ".jpg"; using (var image1 = File.OpenWrite(putimag)) { response1.GetResponseStream().CopyTo(image1); } } Excel(str, put, silkaobj, name, artikul, cena, nalichie, opisanie, kategor, gruppa, putimag, allsoptov, proizvoditel, artikul, strana, gabarit, ves, moch, napr, dopopisanie, osnxar, allzapchasti, putinst, allanalogi, allsopdlya); } incCallBack?.Invoke(); inet = 0; if (proxchet == proxy.Count - 1) { proxchet1 = 0; } objectchet = 0; proxchet1++; break; } catch (WebException) { if (proxchet == proxy.Count - 1) { proxchet1 = 0; } objectchet = i; proxchet1++; inet++; continue; } catch (IOException) { if (proxchet == proxy.Count - 1) { proxchet1 = 0; } objectchet = i; proxchet1++; inet++; continue; } } } }
public static void GetObj(string put, ProgressCallBack incCallBack, ProgressMax maximum, int sdelano, int stroka) { ExcelStr = stroka; string putimag = "", putinst = ""; CookieContainer cookies = new CookieContainer(); HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("http://www.entero.ru/vendors/"); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse(); StreamReader streamReader = new StreamReader(response1.GetResponseStream()); string result = streamReader.ReadToEnd(); Regex regex = new Regex("(?<=<a href=/vendors)[\\w\\W]*?(?=>)"); int k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] allvend = new string[k]; k = 0; foreach (Match match in regex.Matches(result)) { allvend[k] = match.Value; k++; } maximum?.Invoke(allvend.Length); for (int chetvend = sdelano; chetvend <= allvend.Length; chetvend++) { request1 = (HttpWebRequest)WebRequest.Create("http://www.entero.ru/vendors" + allvend[chetvend]); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); regex = new Regex("(?<=<a href=/list).*?(?=><img)"); k = 0; foreach (Match match in regex.Matches(result)) { k++; } string [] allkatal = new string[k]; k = 0; foreach (Match match in regex.Matches(result)) { allkatal[k] = match.Value; k++; } for (int katalchet = 0; katalchet < allkatal.Length; katalchet++) { request1 = (HttpWebRequest)WebRequest.Create("http://www.entero.ru/list" + allkatal[katalchet] + "&p=1"); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); regex = new Regex("(?<=<span>)\\d.*?(?=</span>)"); int kolstr = 1; foreach (Match match in regex.Matches(result)) { kolstr++; } for (int strchet = 1; strchet <= kolstr; strchet++) { request1 = (HttpWebRequest)WebRequest.Create("http://www.entero.ru/list" + allkatal[katalchet] + "&p=" + strchet); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); regex = new Regex("(?<=m><a href=).*?(?= title=)"); k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] allobj = new string[k]; k = 0; foreach (Match match in regex.Matches(result)) { allobj[k] = match.Value; k++; } for (int objchet = 0; objchet < allobj.Length; objchet++) { string silkobj = "http://www.entero.ru" + allobj[objchet]; request1 = (HttpWebRequest)WebRequest.Create(silkobj); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); streamReader = new StreamReader(response1.GetResponseStream()); result = streamReader.ReadToEnd(); name = Regex.Match(result, "(?<=<title>).*?(?=</title>)").Value; nalichie = Regex.Match(result, "(?<=lowercase;'>).*?(?=</span>)").Value; artikul = Regex.Match(result, "(?<=Код товара: <b>).*?(?=</b>)").Value; cena = Regex.Match(result, "(?<=price\">).*?(?=</div>)").Value.Replace(" ", " ").Replace(" ", " "); opisanie = Regex.Match(result, "(?<=>Описание)[\\w\\W]*?(?=</div></div>)").Value; opisanie = Regex.Replace(opisanie, "<.*?>", string.Empty).Replace(" ", "").Replace("\n", "").Replace(""", "\"").Replace("°", "").Replace("\t", " ").Replace(" ", " "); kategor = Regex.Match(result, "(?<=href=/categories/\\d*?>).*?(?=</a>)").Value; regex = new Regex("(?<=href=/categories/\\d*?>).*?(?=</a>)"); k = 0; foreach (Match match in regex.Matches(result)) { k++; } string[] allgru = new string[k]; k = 0; foreach (Match match in regex.Matches(result)) { allgru[k] = match.Value; k++; } string inst = Regex.Match(result, "(?<=pdf'><a href=).*(?=>Инструкция)").Value; gruppa = allgru[k - 1]; image = Regex.Match(result, "(?<=image src=//).*?(?= alt)").Value; proizvoditel = Regex.Match(result, "(?<=Все товары ).*?(?=</a>)").Value; kod = artikul; strana = Regex.Match(result, "(?<=Страна-производитель<span></td><td class=value>).*?(?=</td>)").Value; string shir = Regex.Match(result, "(?<=Ширина)<.*?(?=<td class=name>)").Value; shir = Regex.Replace(shir, "<.*?>", string.Empty).Replace(" ", " "); string vis = Regex.Match(result, "(?<=Высота)<.*?(?=<td class=name>)").Value; vis = Regex.Replace(vis, "<.*?>", string.Empty).Replace(" ", " "); if (vis != "" && shir != "") { gabarit = String.Concat(shir, " x ", vis); } else if (vis != "" && shir == "") { gabarit = vis; } else if (vis == "" && shir != "") { gabarit = shir; } string glub = Regex.Match(result, "(?<=Глубина)<.*?(?=<td class=name>)").Value; glub = Regex.Replace(glub, "<.*?>", string.Empty).Replace(" ", " "); if (gabarit != "" && glub != "") { gabarit = String.Concat(gabarit, " x ", glub); } else if (gabarit == "" && glub != "") { gabarit = glub; } vec = Regex.Match(result, "(?<=Вес ).*?(?=<td class=name>)").Value; vec = Regex.Replace(vec, "<.*?>", string.Empty).Replace(" ", " "); moch = Regex.Match(result, "(?<=Мощность).*?(?=<td class=name>)").Value; moch = Regex.Replace(moch, "<.*?>", string.Empty).Replace(" ", " "); napr = Regex.Match(result, "(?<=Напряжение).*?(?=<td class=name>)").Value; if (napr == "") { napr = Regex.Match(result, "(?<=Питание).*?(?=<td class=name>)").Value; } if (napr == "") { napr = Regex.Match(result, "(?<=Подключение).*?(?=<td class=name>)").Value; } napr = Regex.Replace(napr, "<.*?>", string.Empty).Replace(" ", " "); osnxar = Regex.Match(result, "(?<=<td class=name>).*?(?=</table>)").Value; osnxar = Regex.Replace(osnxar, "<.*?>", " ").Replace(" ", " ").Replace(" ", ""); garanti = Regex.Match(result, "(?<=Гарантия:).*?(?=.</span>)").Value; garanti = Regex.Replace(garanti, "<.*?>", ""); DirectoryInfo dirInfo = new DirectoryInfo(put + "\\" + kategor + "\\" + gruppa); if (!dirInfo.Exists) { dirInfo.Create(); } if (image != "") { request1 = (HttpWebRequest)WebRequest.Create("http://" + image); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); putimag = put + "\\" + kategor + "\\" + gruppa + "\\" + katalchet + strchet + objchet + ".jpg"; using (var image1 = File.OpenWrite(putimag)) { response1.GetResponseStream().CopyTo(image1); } } if (inst != "") { request1 = (HttpWebRequest)WebRequest.Create("http://www.entero.ru" + inst); request1.CookieContainer = cookies; request1.Headers["Upgrade-Insecure-Requests"] = "1"; request1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; request1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; response1 = (HttpWebResponse)request1.GetResponse(); putinst = put + "\\" + kategor + "\\" + gruppa + "\\" + katalchet + strchet + objchet + ".pdf"; using (var image1 = File.OpenWrite(putinst)) { response1.GetResponseStream().CopyTo(image1); } } Excel(chetvend, silkobj, name, artikul, cena, nalichie, opisanie, kategor, gruppa, putimag, proizvoditel, kod, strana, gabarit, vec, moch, napr, osnxar, putinst, garanti); } } } incCallBack?.Invoke(); } }