예제 #1
0
        private void SetOriginalNumbers(IntercarsProfile profile)
        {
            if (profile.NomerOe == "")
            {
                return;
            }
            ReqParametres req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_getsoap.php?call=numoe&art={profile.NomerOe}&wit=ICKATALOGWEB", HttpMethod.POST, $"call=numoe&art={profile.NomerOe}&wit=ICKATALOGWEB");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser    link    = new LinkParser(req.Request);
            List <string> numbers = link.Data.ParsRegex("> ([0-9]+)", 1);

            for (int i = 0; i < numbers.Count; i++)
            {
                if (i == 0)
                {
                    profile.OriginalNumbers = numbers[i];
                }
                else
                {
                    profile.OriginalNumbers += ";\n" + numbers[i];
                }
            }
        }
예제 #2
0
        private void ParsInfo(Zillow zillow)
        {
            Thread thread = new Thread(() =>
            {
                LinkParser linkParser;
                ReqParametres reqParametres;
                do
                {
                    //Парсим предварительную ссылку
                    reqParametres = new ReqParametres(zillow.URL);
                    reqParametres.SetUserAgent(Useragents.GetNewUseragent());
                    reqParametres.SetProxy();
                    linkParser   = new LinkParser(reqParametres.Request);
                    SavedCookies = linkParser.Cookies;
                } while (isCaptcha(linkParser.Data));
                string newLink = linkParser.Data.ParsFromTo("<link rel=\"canonical\" href=\"", "\"");
                //Проверяем на неверную ссылку
                if (newLink.Contains("https://www.zillow.com/homes/for_sale/"))
                {
                    zillow.Status = "No such adress";
                }
                else
                {
                    zillow.URL = newLink;

                    do
                    {
                        reqParametres = new ReqParametres(zillow.URL);
                        reqParametres.SetUserAgent(Useragents.GetNewUseragent());
                        reqParametres.SetProxy();
                        linkParser = new LinkParser(reqParametres.Request);
                    } while (isCaptcha(linkParser.Data));
                    zillow.Status = CheckOnStatus(linkParser.Data.ToLower()).Replace("<span tabindex=\"0\" role=\"button\"><span class=\"zsg-tooltip-launch_keyword\">", "")
                                    .Replace("<Span Tabindex=\"0\" Role=\"Button\"><Span Class=\"Zsg-Tooltip-Launch_Keyword\">", "");
                    if (zillow.Status.Equals("Undefined"))
                    {
                        DebugBox.WriteLine(linkParser.Data);
                    }
                    else
                    {
                        //Zestimate set
                        List <string> rawZestimate = linkParser.Data.ParsRegex("Zestimate<sup>®</sup></span></span>(.*?)\\$([0-9,./a-zA-Z]+)<", 2);
                        if (rawZestimate.Count != 0)
                        {
                            zillow.Zestimate = "$" + rawZestimate[0];
                        }
                        zillow.SoldPrice = CheckPrice(linkParser.Data);
                    }
                    SavedCookies = linkParser.Cookies;
                }
                threadCount--;
                progress++;
                DebugBox.WriteLine($"Обработано ссылок: {progress} из {results.Count}.");
                double val = 100.0f / results.Count * progress;
                WorkProgress.SetValue(val);
            });

            thread.IsBackground = true;
            thread.Start();
        }
예제 #3
0
        private void SetModel(IntercarsProfile profile, string data)
        {
            string numerOe = data.ParsFromTo("daj_numeryOE('", "'");

            profile.NomerOe = numerOe;
            if (numerOe == "")
            {
                return;
            }
            ReqParametres req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_getsoap.php?call=stos&art={numerOe}&wit=ICKATALOGWEB", HttpMethod.POST, $"call=stos&art={numerOe}&wit=ICKATALOGWEB");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser link = new LinkParser(req.Request);

            profile.Mark = link.Data.ParsFromTo("class=\"dZB1\" ><u>", "<");
            List <string> models = link.Data.Replace("\n", "").Replace("\r", "").ParsRegex("class=\"dZB2\"><u>(.*?)<", 1);

            for (int i = 0; i < models.Count; i++)
            {
                if (i == 0)
                {
                    profile.Model = models[i];
                }
                else
                {
                    profile.Model += ";\n" + models[i];
                }
            }
        }
예제 #4
0
        public override void CrawlData()
        {
            string baid = "-1";

            for (int i = 0; i < MaxPageNumber; i++)
            {
                try
                {
                    LinkParser linkParser;
                    do
                    {
                        ReqParametres reqParametres = new ReqParametres("https://ru.auctions.godaddy.com/trpSearchResults.aspx", HttpMethod.Post, $"t=5&action=search&hidAdvSearch=ddlAdvKeyword:3|txtKeyword:|ddlCharacters:0|txtCharacters:|txtMinTraffic:|txtMaxTraffic:|txtMinDomainAge:|txtMaxDomainAge:|txtMinPrice:|txtMaxPrice:|ddlCategories:0|chkAddBuyNow:false|chkAddFeatured:false|chkAddDash:true|chkAddDigit:true|chkAddWeb:false|chkAddAppr:false|chkAddInv:false|chkAddReseller:false|ddlPattern1:|ddlPattern2:|ddlPattern3:|ddlPattern4:|chkSaleOffer:false|chkSalePublic:false|chkSaleExpired:false|chkSaleCloseouts:false|chkSaleUsed:false|chkSaleBuyNow:false|chkSaleDC:false|chkAddOnSale:false|ddlAdvBids:0|txtBids:|txtAuctionID:|ddlDateOffset:|ddlSort:auctionendtimeD&rtr=7&baid={baid}&searchDir=1");
                        reqParametres.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.38 Safari/537.36");
                        reqParametres.RowRequest.ContentType = "application/x-www-form-urlencoded";
                        linkParser = new LinkParser(reqParametres.Request);
                    } while (!linkParser.Data.Contains("onclick=\"_s_baid"));

                    Sites.AddRange(linkParser.Data.ParsRegex("alt=\"\" />(.*?)<", 1).Select(x => new Site {
                        Link = x
                    }));

                    baid = linkParser.Data.ParsFromTo("onclick=\"_s_baid1=", ";");
                    if (string.IsNullOrEmpty(baid))
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    Thread.Sleep(5000);
                    Console.WriteLine(e.Message + "\n");
                }
            }
        }
예제 #5
0
        private string UploadImageToGoogle()
        {
            try
            {
                Console.Write("Trying connection to new proxy: ");
                ReqParametres req = new ReqParametres($"https://www.google.com/searchbyimage?image_url={_imageUrl}");
                req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.53 Safari/537.36");
                //req.SetProxy(5000, Proxies.GetProxy());
                LinkParser link = new LinkParser(req.Request);
                if (link.IsError)
                {
                    Proxies.DeleteFirstProxy();
                    return(UploadImageToGoogle());
                }

                if (link.Data.ParsFromTo("role=\"heading\"><a href=\"", "\"") == "")
                {
                    Proxies.DeleteFirstProxy();
                    return(UploadImageToGoogle());
                }
                Console.WriteLine("Succes!");
                return("https://www.google.com" + link.Data.ParsFromTo("role=\"heading\"><a href=\"", "\"").Replace("amp;", ""));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Proxies.DeleteFirstProxy();
                return(UploadImageToGoogle());
            }
        }
예제 #6
0
        public TelegramChecker(string url, int reconnects)
        {
            triesToConnect = reconnects;
            Url            = url;
            LinkParser linkParser = null;

            do
            {
                ReqParametres req = new ReqParametres(url);
                _currentProxy = Proxies.GetProxy();
                req.SetProxy(_currentProxy);
                req.SetTimout(8000);
                linkParser = new LinkParser(req.Request);
            }while (triesToConnect-- > 0 && linkParser.IsError);

            if (!linkParser.IsError)
            {
                string title = linkParser.Data.ParsFromTo("<title>", "</title>");
                string data  = linkParser.Data.ParsFromTo("<div class=\"tgme_page_extra\">", "</div>");
                SetType(title, data);
                SetMembers(data);
                Proxies.ReturnProxie(_currentProxy);
            }
            else
            {
                IsError = true;
            }
        }
예제 #7
0
        private void CheckTrust()
        {
            LinkParser linkParser;

            do
            {
                ReqParametres reqParametres = new ReqParametres($"https://checktrust.ru/app.php?r=host/app/summary/basic&applicationKey=619f496e644ba8edcd702704176a7b26&host={_site.Link}&parameterList=spam,mjDin,mjCF,mjTF");
                linkParser = new LinkParser(reqParametres.Request);
                try
                {
                    _site.Bl           = decimal.Parse(linkParser.Data.ParsFromTo("mjDin\":\"", "\""), CultureInfo.InvariantCulture);
                    _site.TrustFlow    = decimal.Parse(linkParser.Data.ParsFromTo("mjTF\":\"", "\""), CultureInfo.InvariantCulture);
                    _site.CitationFlow = decimal.Parse(linkParser.Data.ParsFromTo("mjCF\":\"", "\""), CultureInfo.InvariantCulture);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                if (linkParser.Data.Contains("message\":\"Host "))
                {
                    Thread.Sleep(TimeSpan.FromSeconds(5));
                }
            } while (linkParser.Data.Contains("message\":\"Host "));
        }
예제 #8
0
        private void SetZaminniki(IntercarsProfile profile, string data)
        {
            string parametres = data.ParsFromTo("&sta=T&fir=UJ8&gru=", "\"");

            profile.Gru = parametres;
            if (parametres == "")
            {
                return;
            }


            ReqParametres req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_zamienniki.php?popup=T&firgru={parametres}&towkod={profile.TovarCode}&zakres=all");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser    link      = new LinkParser(req.Request);
            List <string> zaminniki = link.Data.ParsRegex(" <b>(.*?)<", 1);

            for (int i = 0; i < zaminniki.Count; i++)
            {
                if (i == 0)
                {
                    profile.Zaminniki = zaminniki[i];
                }
                else
                {
                    profile.Zaminniki += ";\n" + zaminniki[i];
                }
            }
        }
예제 #9
0
        private void SetParametres(IntercarsProfile profile)
        {
            ReqParametres req = new ReqParametres("https://ic-ua.intercars.eu/dynamic/uni/ws_towDetail.php?wit=ICKATALOGWEB&p=F", HttpMethod.POST, $"artnr={profile.Number}&witryna=ICKATALOGWEB&towkod={profile.TovarCode}&lang=RU&nb=N&kraj=UA&typ=&wsk=");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser link = new LinkParser(req.Request);

            profile.Description = link.Data.ParsFromTo("<title>", "<");

            profile.Image = link.Data.ParsFromTo("<img  src=\"", "\"");
            if (profile.Image != "")
            {
                profile.Image = "https://ic-ua.intercars.eu" + profile.Image;
            }

            SetModel(profile, link.Data);
            SetZaminniki(profile, link.Data);
            SetOriginalNumbers(profile);
            List <string> additionalInformation = link.Data.ParsRegex("dKartaNazClass(.*?)>(.*?)<", 2);

            for (int i = 0; i < additionalInformation.Count; i += 2)
            {
                if (i == 0)
                {
                    profile.AdditionalInformation = additionalInformation[i] + " " + additionalInformation[i + 1];
                }
                else
                {
                    profile.AdditionalInformation += "\n" + additionalInformation[i] + " " + additionalInformation[i + 1];
                }
            }
            SetPrices(profile, link.Data);
        }
예제 #10
0
        private void SetTovarCode(IntercarsProfile profile)
        {
            ReqParametres req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/uni/ws_towary.php?wit=ICKATALOGWEB&pro=&kraj=UA&oesearch={profile.Number}&ofe=", HttpMethod.POST, $"oesearch={profile.Number}");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser link = new LinkParser(req.Request);

            List <string> allCodes  = link.Data.Replace("\n", "").Replace("\r", "").ParsRegex("Daj_Katalog_Detail_Clob(.*?);", 1);
            List <string> uniqCodes = new List <string>();

            allCodes.ForEach(
                code =>
            {
                string rawCode = code.Split(',')[code.Split(',').Length - 1].ParsFromTo("'", "'");
                if (!uniqCodes.Contains(rawCode) && Regex.IsMatch(rawCode, "[A-Z0-9]+"))
                {
                    uniqCodes.Add(rawCode);
                }
            });
            if (uniqCodes.Count > 0)
            {
                profile.TovarCode = uniqCodes[0];
            }
            else
            {
                profile.TovarCode = "";
            }
        }
예제 #11
0
        private void SetCookies(ReqParametres req)
        {
            CookieContainer cookieContainer = new CookieContainer();

            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("khkod", "U" + _khcode));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("lang", "UA"));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("kraj", "UA"));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("PHPSESSID", "elo485mp69q42ejdgjssd23ev4"));
            req.SetCookie(cookieContainer);
        }
예제 #12
0
        private void GetAllGoogleImageLinks(string googleUrl)
        {
            for (int i = 0; i < 10000; i += 100)
            {
                try
                {
                    Console.WriteLine($"Trying to get page {i/100} of Google search results.");
                    ReqParametres req;
                    if (i == 0)
                    {
                        req = new ReqParametres($"{googleUrl}&async=_id:rg_s,_pms:s,_jsfs:Ffpdje,_fmt:pc&asearch=ichunk");
                    }
                    else
                    {
                        req = new ReqParametres($"{googleUrl}&start={i}&ijn={i / 100}&async=_id:rg_s,_pms:s,_jsfs:Ffpdje,_fmt:pc&asearch=ichunk");
                    }
                    req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.53 Safari/537.36");
                    //req.SetProxy(3000, Proxies.GetProxy());
                    LinkParser linkParser = new LinkParser(req.Request);
                    if (linkParser.IsError)
                    {
                        throw new Exception();
                    }
                    List <string> allLinksOnSite = linkParser.Data.ParsRegex("\"ou\":\"(.*?)\"", 1);
                    if (allLinksOnSite.Count == 0)
                    {
                        break;
                    }

                    allLinksOnSite.ForEach(
                        x =>
                    {
                        if (x.ToLower().EndsWith(".jpg") || x.ToLower().EndsWith(".jpeg") ||
                            x.ToLower().EndsWith(".png"))
                        {
                            CrowledImageLinks.Add(x);
                        }
                    });
                    Console.WriteLine($"{_imagePath}.....Found {CrowledImageLinks.Count} images.");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed.");
                    Proxies.DeleteFirstProxy();
                    i -= 100;
                    continue;
                }
            }
        }
예제 #13
0
        private void CookieSet()
        {
            LinkParser linkParser;

            do
            {
                ReqParametres reqParametres = new ReqParametres("https://www.zillow.com/");
                reqParametres.SetUserAgent(Useragents.GetNewUseragent());
                //reqParametres.SetProxy();
                if (SavedCookies != null)
                {
                    reqParametres.SetCookie(SavedCookies);
                }
                linkParser   = new LinkParser(reqParametres.Request);
                SavedCookies = linkParser.Cookies;
            } while (isCaptcha(linkParser.Data));
        }
예제 #14
0
        private void SetPrices(IntercarsProfile profile, string data)
        {
            if (profile.Gru == "")
            {
                return;
            }
            if (data.Contains("checked id=\"VATNF\""))
            {
                profile.PriceType = "З ПДВ";
            }
            else
            {
                profile.PriceType = "Без ПДВ";
            }

            ReqParametres req;

            if (profile.PriceType == "З ПДВ")
            {
                req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_getsoap.php?towkod={profile.TovarCode}&call=dkc&cen=HB-DB-HN-DN&qty=1&sta=T&fir=UJ8&gru={profile.Gru}");
            }
            else
            {
                req = new ReqParametres($"https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_getsoap.php?towkod={profile.TovarCode}&call=dkc&cen=HN-DN-HB-DB&qty=1&sta=T&fir=UJ8&gru={profile.Gru}");
            }
            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            SetCookies(req);
            req.RowRequest.ContentType = "application/x-www-form-urlencoded";
            LinkParser link = new LinkParser(req.Request);

            string[] prices = link.Data.Split('^');
            if (prices.Length > 0)
            {
                profile.PriceRozdrib = prices[0] + " UAH";
            }

            if (prices.Length > 1)
            {
                profile.PriceOpt                  = prices[1] + " UAH";
                profile.OnlineAvailability        = prices[prices.Length - 3].Replace("&gt;", ">");
                profile.AvailabilityInBranchGroup = prices[prices.Length - 2];
                profile.AvailabilityInViddelenni  = prices[prices.Length - 1];
            }
        }
예제 #15
0
        private void SetKhcodeProcess(int count)
        {
            Thread thread = new Thread(
                (() =>
            {
                for (int i = count; i < count + 1000; i++)
                {
                    _count++;
                    if (Khcode != "")
                    {
                        break;
                    }

                    ReqParametres req = new ReqParametres(
                        "https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_zamienniki.php?popup=T&firgru=|UJ5|UJ8|UR1|UR3&towkod=BC421D&zakres=all");
                    req.SetUserAgent(
                        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
                    CookieContainer cookieContainer = new CookieContainer();
                    cookieContainer.Add(
                        new Uri("https://ic-ua.intercars.eu/"),
                        new Cookie("khkod", "U" + i));
                    cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("lang", "UA"));
                    cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("kraj", "UA"));
                    cookieContainer.Add(
                        new Uri("https://ic-ua.intercars.eu/"),
                        new Cookie("PHPSESSID", "elo485mp69q42ejdgjssd23ev4"));
                    req.SetCookie(cookieContainer);
                    LinkParser link = new LinkParser(req.Request);
                    List <string> zaminniki = link.Data.ParsRegex(" <b>(.*?)<", 1);
                    if (zaminniki.Count > 0)
                    {
                        Khcode = i.ToString();
                        break;
                    }
                }
            }));

            thread.IsBackground = true;
            thread.Start();
        }
예제 #16
0
        private bool GoogleCheck()
        {
            return(true);

            LinkParser linkParser;
            // do
            // {
            //     ReqParametres reqParametres = new ReqParametres("https://www.google.com/search?q=site:"+_site.Link);
            //     reqParametres.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.38 Safari/537.36");
            //     reqParametres.SetProxy(Proxies.GetProxy());
            //     linkParser = new LinkParser(reqParametres.Request);
            //     if (linkParser.IsError || linkParser.Data.Contains("recaptcha"))
            //     {
            //         Thread.Sleep(2000);
            //     }
            // } while (linkParser.IsError|| linkParser.Data.Contains("recaptcha"));
            ReqParametres reqParametres = new ReqParametres("https://www.google.com/search?q=site:" + _site.Link);

            reqParametres.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.38 Safari/537.36");
            // reqParametres.SetProxy(Proxies.GetProxy());
            linkParser = new LinkParser(reqParametres.Request);
            return(linkParser.Data.Contains("result-stats\">"));
        }
예제 #17
0
        private bool IsValidCode(string code)
        {
            ReqParametres req = new ReqParametres("https://ic-ua.intercars.eu/dynamic/ickatalogweb/ws_zamienniki.php?popup=T&firgru=|UJ5|UJ8|UR1|UR3&towkod=BC421D&zakres=all");

            req.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.34 Safari/537.36");
            CookieContainer cookieContainer = new CookieContainer();

            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("khkod", "U" + code));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("lang", "UA"));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("kraj", "UA"));
            cookieContainer.Add(new Uri("https://ic-ua.intercars.eu/"), new Cookie("PHPSESSID", "elo485mp69q42ejdgjssd23ev4"));
            req.SetCookie(cookieContainer);
            LinkParser    link      = new LinkParser(req.Request);
            List <string> zaminniki = link.Data.ParsRegex(" <b>(.*?)<", 1);

            if (zaminniki.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #18
0
        private void WebArchiveCrawl()
        {
            ReqParametres    reqParametres = new ReqParametres($"https://web.archive.org/cdx/search/cdx?url={_site.Link}&filter=statuscode:30.&output=json&fl=timestamp,original,digest&collapse=length");
            LinkParser       linkParser    = new LinkParser(reqParametres.Request);
            var              timeStamps    = linkParser.Data.ParsRegex("\\[\"([0-9]+)\"", 1);
            List <Redirects> redirects     = new List <Redirects>();
            object           locker        = new object();

            timeStamps.ForEach(timestamp =>
            {
                do
                {
                    reqParametres      = new ReqParametres($"http://web.archive.org/web/{timestamp}/{_site.Link}");
                    linkParser         = new LinkParser(reqParametres.Request);
                    string redirect    = linkParser.Data.ParsFromTo("Got an HTTP ", " ");
                    string redirectUrl = linkParser.Data.ParsFromTo("<p class=\"code\">Redirecting to...</p>", "<p class=\"impatient\">").ParsFromTo("<p class=\"code shift target\">", "</p>");
                    if (!string.IsNullOrEmpty(redirect) && !string.IsNullOrEmpty(redirectUrl))
                    {
                        lock (locker)
                        {
                            redirects.Add(new Redirects
                            {
                                RedirectCode = redirect,
                                RedirectLink = redirectUrl
                            });
                        }
                    }

                    if (linkParser.Data.Contains("Too Many Requests") || linkParser.IsError)
                    {
                        Thread.Sleep(10000);
                    }
                } while (linkParser.Data.Contains("Too Many Requests") || linkParser.IsError);
            });
            _site.Redirects = redirects;
        }
예제 #19
0
        private void WhoisChecking()
        {
            new Thread(() =>
            {
                while (true)
                {
                    bool hasSitesToCheck;
                    lock (_locker)
                    {
                        hasSitesToCheck = _sitesToCheck.Count > 0;
                    }

                    if (hasSitesToCheck)
                    {
                        LinkParser linkParser;
                        ReqParametres reqParametres;
                        //Проверяем доступность ПО
                        do
                        {
                            reqParametres = new ReqParametres("http://localhost:8079/greeting");
                            linkParser    = new LinkParser(reqParametres.Request);
                            if (!linkParser.Data.Contains("ok\" : true"))
                            {
                                Thread.Sleep(1000);
                            }
                        } while (!linkParser.Data.Contains("ok\" : true"));

                        //Отправляем данные на проверку
                        lock (_locker)
                        {
                            reqParametres = new ReqParametres("http://localhost:8079/add", HttpMethod.Post, JsonConvert.SerializeObject(new DomainsContainer {
                                domains = _sitesToCheck
                            }));
                            _sitesToCheck.Clear();
                        }
                        new LinkParser(reqParametres.Request);

                        //Запускаем парсинг whois
                        reqParametres = new ReqParametres("http://localhost:8079/run?parser=whois");
                        new LinkParser(reqParametres.Request);

                        //Проверяем ответ
                        do
                        {
                            reqParametres = new ReqParametres("http://localhost:8079/domains");
                            linkParser    = new LinkParser(reqParametres.Request);
                            if (!linkParser.Data.Contains("\"scanning\" : false"))
                            {
                                Thread.Sleep(1000);
                            }
                        } while (!linkParser.Data.Contains("\"scanning\" : false"));

                        var allSites = linkParser.Data.ParsRegex("\"name\" : \"(.*?)\"(.*?)Created\" : \"(.*?)\"", 1);
                        var allDates = linkParser.Data.ParsRegex("\"name\" : \"(.*?)\"(.*?)Created\" : \"(.*?)\"", 3);
                        lock (_locker)
                        {
                            for (int i = 0; i < allSites.Count && i < allDates.Count; i++)
                            {
                                if (DateTime.TryParse(allDates[i], out DateTime result))
                                {
                                    if (_startDate.CompareTo(result) <= 0)
                                    {
                                        _sitesToCheckAfterWhois.Push(new Site {
                                            Link = allSites[i], SiteType = SiteType.ToCheck
                                        });
                                    }
                                    else
                                    {
                                        ControlsContainer.StartWhois++;
                                        _amountToCheck--;
                                    }
                                }
                                else
                                {
                                    ControlsContainer.StartWhois++;
                                    _amountToCheck--;
                                }
                            }
                        }

                        //Очищаем данные в ПО
                        reqParametres = new ReqParametres("http://localhost:8079/clear");
                        new LinkParser(reqParametres.Request);
                    }
                    Thread.Sleep(1000);
                }
            })
            {
                IsBackground = true
            }.Start();