コード例 #1
0
        public static void GetImageFromDescription(GetMultipleItemsResponse items, GetMultipleItemsResponse itemsDesc)
        {
            if (items != null && items.Item != null && items.Item.Count() > 0)
              {
            for (var i = 0; i < items.Item.Count(); i++)
            {
              var doc = new HtmlDocument();
              doc.LoadHtml(items.Item[i].Description);

              var desc = HttpUtility.HtmlDecode(GetText(doc.DocumentNode).Replace("&nbsp;", ""));

              desc = Regex.Replace(desc, "<[\\s|\\S]+?>", string.Empty);
              desc = Regex.Replace(desc, "\\t", "");
              string paatern = "(\r\n){2,}";
              string paatern2 = "(\r\n ){2,}";
              string pattern3 = ".+\\{[\\s|\\S]+?\\}";
              string trueDesc = Regex.Replace(desc, pattern3, string.Empty);

              trueDesc = Regex.Replace(trueDesc, "<[\\s|\\S]+?>", string.Empty);
              trueDesc = Regex.Replace(trueDesc, "( ){2,}", " ");
              trueDesc = Regex.Replace(trueDesc, "(\n){2,}", "\n");
              trueDesc = Regex.Replace(trueDesc, "( \n){2,}", "\n");

              trueDesc = Regex.Replace(trueDesc, paatern, "\r\n");
              trueDesc = Regex.Replace(trueDesc, paatern2, "\r\n ");
              trueDesc = Regex.Replace(trueDesc, "( \r\n){2,}", "\r\n ");
              trueDesc = Regex.Replace(trueDesc, "(\n){2,}", "\n");

              items.Item[i].Description = trueDesc.Trim();
              items.Item[i].PictureURL = NewArrayImg(items.Item[i].PictureURL, doc);
            }
              }
        }
コード例 #2
0
ファイル: MySqlDB.cs プロジェクト: ruslanruslanruslan/Parser
        public int UpdateAuction(GetMultipleItemsResponse list, out string TimeLeft)
        {
            //Тело запроса!!!!!!!
              const string sql = @"update fct_grabber_ebay set price=@price where ebay_id=@id";
              decimal price = 0;
              ulong id = 0;
              var published = 0;
              TimeLeft = "ERROR";
              try
              {
            foreach (var item in list.Item)
            {
              TimeLeft = item.TimeLeft;
              var is_auction = item.TimeLeft == "PT0S";
              if (!is_auction)
            break;

              var cmd = new MySqlCommand();
              cmd.Connection = mySqlConnection;
              cmd.CommandText = sql;
              cmd.Prepare();
              //Параметры для вставки типа в теле @phone тут мы  list[PartsPage.Phone].First<string>()
              // и тд
              price = item.CurrentPrice.Value;
              id = item.ItemID;
              cmd.Parameters.AddWithValue("@price", price);
              cmd.Parameters.AddWithValue("@id", id);
              var result = cmd.ExecuteNonQuery();

              if (Properties.Default.PublishParsedData)
              {
            ExecuteProcEBay(GetEBayIDResourceListByEBayID(Convert.ToString(id)));
            published = 1;
              }
            }
              }
              catch (Exception ex)
              {
            throw new Exception("MySql error: [" + sql + "] [price = " + price + "] [id = " + id + "]: " + ex.Message, ex);
              }
              return published;
        }
コード例 #3
0
ファイル: MySqlDB.cs プロジェクト: ruslanruslanruslan/Parser
 //Метод вставки данных в базу!!!!!!!!
 public void InsertFctEbayGrabber(GetMultipleItemsResponse list, string section)
 {
     if (list != null && list.Item != null && list.Item.Length > 0)
       {
     try
     {
       foreach (var item in list.Item)
     InsertEbay(item, section);
     }
     catch (Exception ex)
     {
       throw new Exception("MySql error: " + ex.Message, ex);
     }
       }
 }