Exemple #1
0
        private void Refreshal1(object uri)
        {
            //al1 = new ArrayList();
            string url  = (string)uri;
            string url1 = GetFileName(url);

            url1 = url1 + ".csv";
            StreamWriter sw11 = null;

            try
            {
                sw11 = new StreamWriter(url1);

                string          htmlCode = GetPageResource(url);
                string          CurUrl;
                MatchCollection m = regex.Matches(htmlCode);
                foreach (Match mc in m)
                {
                    lock (this)
                    {
                        CurUrl = mc.Value.Substring(6, mc.Value.Length - 7);
                        if (!CurUrl.StartsWith("http"))
                        {
                            CurUrl = BuildUrl(url, CurUrl);
                        }
                        if (CurUrl != null && !al1.Contains(CurUrl) && CurUrl.StartsWith(temp) && CurUrl.Contains(host))
                        {
                            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                                al1.Add(CurUrl);
                                sw11.WriteLine(CurUrl);
                            }));
                            tail += 1;
                            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { textBoxStatus.AppendText(CurUrl + "\r\n"); textBoxStatus.ScrollToEnd(); }));
                        }
                    }
                }
                CurrentThreads -= 1;
                Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { PB.Value += 1; }));
                sw11.Close();
            }
            catch (Exception ex)
            {
            }
            return;
        }
Exemple #2
0
        private void Refreshal(object uri)
        {
            string          url      = (string)uri;
            string          htmlCode = GetPageResource(url);
            string          CurUrl;
            MatchCollection m = regex.Matches(htmlCode);

            foreach (Match mc in m)
            {
                lock (this)
                {
                    CurUrl = mc.Value.Substring(6, mc.Value.Length - 7);
                    if (!CurUrl.StartsWith("http"))
                    {
                        CurUrl = BuildUrl(url, CurUrl);
                    }
                    if (CurUrl != null && !al.Contains(CurUrl) && CurUrl.StartsWith(temp) && CurUrl.Contains(host))
                    {
                        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { al.Add(CurUrl);
                                                                                        sw1.WriteLine(CurUrl); }));
                        tail += 1;
                        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { textBoxStatus.AppendText(CurUrl + "\r\n"); textBoxStatus.ScrollToEnd(); }));
                    }
                }
            }
            CurrentThreads -= 1;
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { PB.Value += 1; }));
            return;
        }