Exemplo n.º 1
0
        private void ExtractCitys(OnCompletedEventArgs e)
        {
            var matches = Regex.Matches(e.pageSoure, @"<a[^>]+href=""*(?<href>/hotel/[^>\s]+)""\s*[^>]*>(?<text>(?!.*img).*?)</a>");

            cityList.Clear();
            foreach (Match m in matches)
            {
                var city = new City
                {
                    CityName = m.Groups["text"].Value,
                    Uri      = new Uri("http://hotels.ctrip.com" + m.Groups["href"].Value)
                };
                if (!cityList.Contains(city))
                {
                    cityList.Add(city);
                }
            }

            Console.WriteLine("城市抓取完成!");
            Console.WriteLine("耗时:" + e.milliseconds + "毫秒");
            Console.WriteLine("线程:" + e.ThreadId);
            Console.WriteLine("地址:" + e.uri.ToString());
            this.Invoke(new Action(() => {
                this.cityListBox.DataSource = cityList;
                cityListBox.SelectedIndex   = 0;
                cityListBox_DoubleClick(this, null);
            }));
        }
Exemplo n.º 2
0
        void hotelListCrawler_OnCompleted(object sender, OnCompletedEventArgs e)
        {
            Console.WriteLine("酒店搜索完成");
            var matches = Regex.Matches(e.pageSoure, "><a[^>]+href=\"*(?<href>/hotel/[^>\\s]+)\"\\s*data-dopost[^>]*><span[^>]+>.*?</span>(?<text>.*?)</a>");

            hotelList.Clear();
            foreach (Match m in matches)
            {
                var hotel = new Hotel
                {
                    HotelName = m.Groups["text"].Value,
                    Uri       = new Uri("http://hotels.ctrip.com" + m.Groups["href"].Value)
                };
                if (!hotelList.Contains(hotel))
                {
                    hotelList.Add(hotel);
                }
            }

            HotelListBox.Invoke(new Action(() =>
            {
                BindingSource bs             = new BindingSource();
                bs.DataSource                = hotelList;
                this.HotelListBox.DataSource = bs;
            }));
        }
Exemplo n.º 3
0
 private void HotelCrawler(OnCompletedEventArgs e)
 {
     hd = ConvertHelper.ConvertWebeleToHotel(e.driver);
     loadHotelInfo();
     CheckBtnStatus();
 }
Exemplo n.º 4
0
 void hotelCrawler_OnCompleted(object sender, OnCompletedEventArgs e)
 {
     HotelCrawler(e);
 }
Exemplo n.º 5
0
        void hotelsCrawler_OnCompleted(object sender, OnCompletedEventArgs e)
        {
            var s = e.pageSoure;

            ExtractCitys(e);
        }