Пример #1
0
        /// <summary>
        /// 插入女演员个人信息
        /// </summary>
        /// <param name="ac"></param>
        /// <param name="strImgUrl"></param>
        /// <returns></returns>
        public bool InsetActerInfo(Acter ac, string strImgUrl)
        {
            string strI = string.Format(@"insert into c_actresses(jp_name,birthday,age,height,cup,bust,waistline,hips,birth_place,hobby,img_url,add_date) 
values('{0}',date_format('{1}','%Y-%m-%d'),{2},{3},'{4}',{5},{6},{7},'{8}','{9}','{10}',date_format('{11}','%Y-%m-%d'))",
                                        ac.Name,
                                        ac.Birthday == "" ? "1900-01-01" : ac.Birthday,
                                        ac.Age == "" ? "0" : ac.Age,
                                        ac.Height == "" ? "0" : ac.Height,
                                        ac.Cup == "" ? "A" : ac.Cup,
                                        ac.Bust == "" ? "0" : ac.Bust,
                                        ac.Waistline == "" ? "0" : ac.Waistline,
                                        ac.Hips == "" ? "0" : ac.Hips,
                                        ac.BirthPlace == "" ? "noinfo" : ac.BirthPlace,
                                        ac.Hobby == "" ? "noinfo" : ac.Hobby,
                                        strImgUrl,
                                        DateTime.Now.ToString("yyyy-MM-dd"));

            try
            {
                db.NonResturn(strI);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// GetActerIndexPageInfo
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="strPhotoUrl"></param>
        /// <param name="strUrl"></param>
        /// <returns></returns>
        private bool GetActerIndexHtmlInfo(string strName, string strPhotoUrl, string strIndexUrl)
        {
            bool  boolResult = false;
            Acter ac         = new Acter();

            ac.Name = strName;

            HtmlWeb      web = new HtmlWeb();
            HtmlDocument doc = web.Load(strIndexUrl);  //加载女演员主页

            try
            {
                HtmlNode           aNode = doc.DocumentNode.SelectSingleNode("//div[@class='photo-info']");
                HtmlNodeCollection htmlNodesActerInfo = aNode.SelectNodes(".//p");  //获取下面的全部p标签
                foreach (var item in htmlNodesActerInfo)
                {
                    if (item.InnerText.Trim().Length > 1)
                    {
                        if (item.InnerText.Trim().Contains("生日"))
                        {
                            ac.Birthday = item.InnerText.Trim().Split(':')[1].Trim();
                            SetListBoxMessage(ac.Birthday);
                        }
                        else if (item.InnerText.Trim().Contains("年龄"))
                        {
                            ac.Age = item.InnerText.Trim().Split(':')[1].Trim();
                            SetListBoxMessage(ac.Age);
                        }
                        else if (item.InnerText.Trim().Contains("身高"))
                        {
                            ac.Height = item.InnerText.Trim().Split(':')[1].Trim().Replace("cm", "");
                            SetListBoxMessage(ac.Height);
                        }
                        else if (item.InnerText.Trim().Contains("罩杯"))
                        {
                            ac.Cup = item.InnerText.Trim().Split(':')[1].Trim();
                            SetListBoxMessage(ac.Cup);
                        }
                        else if (item.InnerText.Trim().Contains("胸围"))
                        {
                            ac.Bust = item.InnerText.Trim().Split(':')[1].Trim().Replace("cm", "");
                            SetListBoxMessage(ac.Bust);
                        }
                        else if (item.InnerText.Trim().Contains("腰围"))
                        {
                            ac.Waistline = item.InnerText.Trim().Split(':')[1].Trim().Replace("cm", "");
                            SetListBoxMessage(ac.Waistline);
                        }
                        else if (item.InnerText.Trim().Contains("臀围"))
                        {
                            ac.Hips = item.InnerText.Trim().Split(':')[1].Trim().Replace("cm", "");
                            SetListBoxMessage(ac.Hips);
                        }
                        else if (item.InnerText.Trim().Contains("出生地"))
                        {
                            ac.BirthPlace = item.InnerText.Trim().Split(':')[1].Trim();
                            SetListBoxMessage(ac.BirthPlace);
                        }
                        else if (item.InnerText.Trim().Contains("爱好"))
                        {
                            ac.Hobby = item.InnerText.Trim().Split(':')[1].Trim();
                            SetListBoxMessage(ac.Hobby);
                        }
                    }
                }

                //女演员的头像下载并保存,并返回本地网址url路径
                strPhotoUrl = f.SaveActerImg(strName, strPhotoUrl);
                //女演员资料插入数据库返回布尔值
                boolResult = data.InsetActerInfo(ac, strPhotoUrl);
            }
            catch (Exception ex)
            {
                SetListBoxMessage("获取女演员基本资料时出错:" + ex.ToString());
            }

            return(boolResult);
        }