/// <summary> /// 获取网站编码 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetUrlCode(string url) { try { //把网址分割,取出域名部分 string[] Urls = url.Split(new string[] { "://", "/" }, StringSplitOptions.RemoveEmptyEntries); if (UrlCode.ContainsKey(Urls[1])) { return(UrlCode[Urls[1]]); } else { UrlCode[Urls[1]] = GetHtml.GetCode(url); return(UrlCode[Urls[1]]); } } catch (Exception ex) { Console.WriteLine(ex.Message); //Exception ex Tool.TextAdditional(ex.Message); return(""); } }
/// <summary> /// 搜索按钮点击 /// </summary> private void Search_Click(object sender, RoutedEventArgs e) { SearchBook searchBook = new SearchBook(); //搜索链接拼凑 searchBook.BookUrl = SearchUrl.Text + Tool.EncodingConvert(SearchBookName.Text, Encoding.GetEncoding(GetHtml.GetCode(SearchUrl.Text))); searchBook.AddressRangeRegular = AddressRangeRegular.Text; searchBook.AddressCuttingRegular = AddressCuttingRegular.Text; searchBook.AddressRegular = AddressRegular.Text; Thread td = new Thread(SearchBook); //把线程设置为后台线程 td.IsBackground = true; td.Start(searchBook); }