private void GetBoardInfo(CMS_BoardModels model) { try { var id = ""; var bName = ""; CrawlerBoardHelper.getBoardIdFromUrl(model.url, ref id, ref bName); model.name = bName; model.id = id; } catch (Exception ex) { } }
public bool CrawlData(string boardID, string createdBy, ref string msg) { NSLog.Logger.Info("CrawlData: " + boardID); var result = true; try { using (var _db = new CMS_Context()) { /* get key by ID */ var keyWord = _db.CMS_Board.Where(o => o.ID.Equals(boardID) && o.Status == (byte)Commons.EStatus.Active).FirstOrDefault(); if (keyWord != null) { /* check time span crawl */ var timeSpanCrawl = DateTime.Now - keyWord.UpdatedDate; /* update crawer date */ var bkTime = keyWord.UpdatedDate; keyWord.UpdatedDate = DateTime.Now; keyWord.UpdatedBy = createdBy; _db.SaveChanges(); if (!string.IsNullOrEmpty(keyWord.CrawlAccountID)) { var _Cookie = keyWord.CMS_Account.Cookies; if (!string.IsNullOrEmpty(_Cookie)) { CrawlerBoardHelper._Cookies = _Cookie; } else { CrawlerHelper._Cookies = "_b = \"AS+B1gn0GdpGgLQl83JubKX1bG19kiuUUvX8lnvITKDHNq2tJcgqXNIQ0cLN+kjq4KM=\"; _pinterest_pfob = enabled; _ga = GA1.2.229901352.1528170174; pnodepath = \"/pin4\"; fba = True; G_ENABLED_IDPS = google; bei = false; logged_out = True; sessionFunnelEventLogged = 1; cm_sub = denied; _auth = 1; csrftoken = fkrSitmDb4vW2kT1G3GfOkcC8mPvl0kV; _pinterest_sess = \"TWc9PSZWaE0xeDZOVm4yL3Yva0VSazRkRjlHR013bk9mdVJBcU9zVEtEOUhXVjhKSFZmZUEreWJiNDYrV3FubVRoVzdqdDF0dmtDcXErcFF6MmlXQUQ3RDVzWERCWTZYZUt4eXMzemkvOGlXRFZQT1J6MjkwampOZlVJUFEvTnNkTUZYMkJ3dGxPTTRKaVIwdGNJY2h1MUhaSHlFT3djd0huNHE0YmtiTTBZR3dVTVB3d0RyYVE4UC8rMjZCYWo2eTJLNGJVSHR6KzRENjlWVE0rNFMxNWdGMUtVL0VtL2RDZktiUFg3M1Y2Z2dEbllPeUxFR3FOdEd6SUJSRTlBMWs1YkJnbTBlWHhwcC9pMmlqRmoydlh0V2VQSGYvYk1zeXlSM2dIU1dmUXIyRWVxWVBPdTYzbHFjcVhYRWRBT0FTQ3VBNmdWMm5QUlREZDdSY2ZQeE1NWklqSUZxNDllVHF1WUVzRFRrRjBXQnZCMVBGTlYxT0UzM1daeHFOUnBBTzliMzFJdmovQ1hQR2Vvc1pkTHNxL1FjT3FrWllTR1d6VHFrd2g5cFBFMmswM3dIa0dOOHVCbGd6aVlKUkJlZlZNeWVyRTBYREcrQVFlUTdRc1NqMlFlQ3RvaWlZMjJXZ1RURmIxNDA2d2JTODRGNk9BYWpoRzVJTUhLMkJ4UDJGb0NmN0NOQXpmZ0FoR08xcElmWmh5S29OeGRadFpDVWR1RGw3ZzZGRS81SlU4UlhSUVlIWm4wRzRJMGFVaTQzdGI3T2ovSCtHR2ZSWlk0M1RCN2JXSmZJRFdQUUpZWVpRMW5ta0pMbXgwT2NZckZJcHg0RTJrTjJlZWJIdXFSdkdJTWNXc2d3NHpXdzFTRGhKVkN4YmY4SCtJaTdSQSt0K2dhc1VDc0tkNnJIeVFhb3BHeDd6OUwvamZsanRKV0ZYNGFmZWFQNGlqNFVqekVFcGUreHU4UGVqZXRuMFVDNE1QbkFuWnJ6YzNjMTF3dVNZUHJ2MjBwMi8xeXNwbnczMlpSa3cvbzVPQUhQSyswNlU4Y2JQaThxNWN1NWtHVm83SWc0YjJVVW1tUWZYcHpWR2RCYS8wRE0yb2RtNUs0NzRteFp4JjVhOXZDbjB5RGtxL1lROE5WOVNDMjB4c1dMND0=\""; } } else { CrawlerHelper._Cookies = "_b = \"AS+B1gn0GdpGgLQl83JubKX1bG19kiuUUvX8lnvITKDHNq2tJcgqXNIQ0cLN+kjq4KM=\"; _pinterest_pfob = enabled; _ga = GA1.2.229901352.1528170174; pnodepath = \"/pin4\"; fba = True; G_ENABLED_IDPS = google; bei = false; logged_out = True; sessionFunnel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ZXRuMFVDNE1QbkFuWnJ6YzNjMTF3dVNZUHJ2MjBwMi8xeXNwbnczMlpSa3cvbzVPQUhQSyswNlU4Y2JQaThxNWN1NWtHVm83SWc0YjJVVW1tUWZYcHpWR2RCYS8wRE0yb2RtNUs0NzRteFp4JjVhOXZDbjB5RGtxL1lROE5WOVNDMjB4c1dMND0=\""; } var boardUrl = HttpUtility.UrlEncode(keyWord.Url); List <CMS_PinOfBoardModels> models = new List <CMS_PinOfBoardModels>(); CrawlerBoardHelper.Get_Tagged_PinOfBoard(ref models, boardUrl, boardID, Commons.PinDefault); if (models != null) { models = models.GroupBy(o => o.id).Select(o => o.First()).ToList(); Parallel.ForEach(models, pin => { CrawlerBoardHelper.Get_Tagged_PinDetail(ref pin, pin.id); }); CreateOrUpdatePinOfBoard(models, createdBy, keyWord.ID, ref msg); } } } NSLog.Logger.Info("ResponseCrawlData: " + boardID, result); } catch (Exception ex) { msg = "Crawl data is unsuccessfully."; result = false; LogHelper.WriteLogs("ErrorCrawlData: " + boardID, JsonConvert.SerializeObject(ex)); NSLog.Logger.Error("ErrorCrawlData: " + boardID, ex); } return(result); }