public void Execute(IJobExecutionContext context) { var comiclst = new List <Comic>(); HttpWebHelper _helper = new HttpWebHelper(); DateTime dt = DateTime.Now; string shortdate = dt.ToDateStr(); var t = _helper.Get <icartoons_comic>("http://www.icartoons.cn/webapi/web/theme_contents.json?type=1&catid=0&content_type=1&page=1&pagesize=5000&sort=0", Encoding.GetEncoding("utf-8")); int sort = 0; foreach (var x in t.items) { try { sort = sort + 1; string bookurl = $"http://www.icartoons.cn/webapi/web/detail.json?type=1&content_id={x.serial_id}"; var data = _helper.Get <icartoons_comic_desc>(bookurl, Encoding.GetEncoding("utf-8")); comiclst.Add(new Comic() { comicname = x.title, authorname = data.author, bookurl = $"http://www.icartoons.cn/portal/csource.html?content_id={x.serial_id}", comiccoversource = x.cover, comiccoverlocal = "", comicdesc = data.description, comicid = "8_" + x.serial_id, isfinished = x.desc.StartsWith("全") ? "已完结" : "连载中", theme = data.theme, isvip = "0", source = 8, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, comicsort = sort, hot = x.views }); } catch (Exception ex) { continue; } } service.ComicCompareBatchAdd(comiclst, 8, DateTime.Now.ToDateStr()); }
public void Execute(IJobExecutionContext context) { string date = DateTime.Now.ToDateStr(); List <Comic> clst = comicmanager.Query(x => x.source == 6 && x.shortdate == date); List <Chapter> plst = new List <Chapter>(); HttpWebHelper _helper = new HttpWebHelper(); var web = new HtmlWeb(); foreach (var c in clst) { try { var data = web.Load(c.bookurl); var updatestr = data.DocumentNode.SelectSingleNode("//div[@class=\"sr-notice__text f-toe\"]").InnerText.Trim(); if (updatestr.Contains("最近更新")) { updatestr = updatestr.Substring(0, updatestr.IndexOf("最近更新")); } else { updatestr = ""; } var chapterdata = _helper.Get <wangyi_chapter>($"https://manhua.163.com/book/catalog/{c.comicid.Replace("6_", "")}.json", Encoding.GetEncoding("utf-8")); if (chapterdata.code == 200) { var t = chapterdata.catalog.sections.First(); var l = t.sections.Last(); plst.Add(new Chapter() { chapterid = c.comicid + "_" + l.sectionId, chaptername = l.title, chapterurl = $"https://manhua.163.com/reader/{l.bookId}/{l.sectionId}#imgIndex=0", sort = t.sections.Count, comicid = c.comicid, retry = 0, source = 6, downstatus = 0, isvip = "0", chaptersource = "", chapterlocal = "", modify = DateTime.Now, shortdate = DateTime.Now.ToDateStr(), chapterupdate = updatestr }); } } catch (Exception ex) { continue; } } service.ChapterCompareBatchAdd(plst, 6, DateTime.Now.ToDateStr()); }
public void Execute(IJobExecutionContext context) { string date = DateTime.Now.ToDateStr(); List <Comic> clst = comicmanager.Query(x => x.source == 11 && x.shortdate == date); List <Chapter> plst = new List <Chapter>(); foreach (var c in clst) { try { HttpWebHelper _helper = new HttpWebHelper(); var bookdata = _helper.Get(c.bookurl, Encoding.GetEncoding("utf-8")); List <Chapter> chapterlst = new List <Chapter>(); Regex regp1 = new Regex("var maxChapterId = \"(?<key1>.*?)\";"); Match matchp1 = regp1.Match(bookdata); string pcountstr = matchp1.Groups["key1"].Value; Regex regp2 = new Regex("<title>(?<key1>.*?)</title>"); Match matchp2 = regp2.Match(bookdata); string chaptername = matchp2.Groups["key1"].Value.Split('_')[1]; int sort = int.Parse(pcountstr); string chapterurl = $"http://m.zhangyue.com/readbook/{c.comicid.Replace("11_", "")}/{sort}/"; plst.Add(new Chapter() { chapterid = c.comicid + "_" + sort, chaptername = chaptername, chapterurl = chapterurl, sort = sort, comicid = c.comicid, retry = 0, source = 11, downstatus = 0, isvip = "0", chaptersource = "", chapterlocal = "", modify = DateTime.Now, shortdate = DateTime.Now.ToDateStr(), chapterupdate = DateTime.Now.ToDateStr() }); } catch (Exception ex) { continue; } } service.ChapterCompareBatchAdd(plst, 11, DateTime.Now.ToDateStr()); }
public string HttpRequest(IDictionary <string, string> dicParams, string responseEncoding = "UTF-8") { var responseStr = ""; HttpWebHelper http = new HttpWebHelper(); if (RequestMethod.ToUpper() == "GET") { var _payUrl = HttpWebHelper.CreateParameter(dicParams); responseStr = http.Get(_payUrl, Encoding.GetEncoding(responseEncoding)); } else { responseStr = http.Post(PayUrl, dicParams, Encoding.GetEncoding(responseEncoding), Encoding.GetEncoding(responseEncoding)); } return(responseStr); }
private void button1_Click(object sender, EventArgs e) { HttpWebHelper httpWebHelper = new HttpWebHelper(); ExceptionMsg exceptionMsg = new ExceptionMsg(); try { string R_result = httpWebHelper.Get("http://baidu.com", Encoding.UTF8); MessageBox.Show(exceptionMsg.IP); } catch (Exception ex) { MessageBox.Show(ex.Message); } //localCache.Add("mykey", "123", 10); localCache.Add("mykey", "123"); localCache.Set("11", DataBindingByList1()); ThreadStart threadStart = new ThreadStart(refresh); Thread thread = new Thread(threadStart); thread.Start(); new Thread(() => { while (true) { Thread.Sleep(1000); SetText($"9999\r\n"); } }) { IsBackground = true }.Start(); dynamic d = 1; int c = d + 1; //MessageBox.Show(c.ToString()); //Greeting("Make", ChineseGreeting); }
public void Execute(IJobExecutionContext context) { string date = DateTime.Now.ToDateStr(); List <Comic> clst = comicmanager.Query(x => x.source == 8 && x.shortdate == date); List <Chapter> plst = new List <Chapter>(); HttpWebHelper _helper = new HttpWebHelper(); foreach (var c in clst) { try { var bookdata = _helper.Get <icartoons_chapter>($"http://www.icartoons.cn/webapi/web/serials.json?type=1&content_id={c.comicid.Replace("8_", "")}&sort=2", Encoding.GetEncoding("utf-8")); var x = bookdata.items.First(); plst.Add(new Chapter() { chapterid = 8 + "_" + x.set_id, chaptername = x.title, chapterurl = $"http://www.icartoons.cn/portal/creader.html?content_id={c.comicid.Replace("8_", "")}&set_id={x.set_id}", sort = x.sortid, comicid = c.comicid, retry = 0, source = 8, downstatus = 0, isvip = "0", chaptersource = "", chapterlocal = "", modify = DateTime.Now, shortdate = DateTime.Now.ToDateStr(), chapterupdate = DateTime.Now.ToDateStr() }); } catch (Exception ex) { continue; } } service.ChapterCompareBatchAdd(plst, 8, DateTime.Now.ToDateStr()); }
public void Execute(IJobExecutionContext context) { DateTime dt = DateTime.Now; string shortdate = dt.ToString("yyyy-MM-dd"); string yesterday = dt.AddDays(-1).ToString("yyyy-MM-dd"); IQuery <Comic> q = dbcontext.Query <Comic>(); IQuery <Chapter> cpq = dbcontext.Query <Chapter>(); List <Comic> comiclst = q.Where(a => a.source == Source.mh160 && a.shortdate == shortdate).Take(200).ToList(); List <int> ids = comiclst.Select(x => x.Id).ToList(); dbcontext.Update <Comic>(a => ids.Contains(a.Id), a => new Comic() { shortdate = yesterday, modify = dt }); List <Chapter> chapterlst = new List <Chapter>(); foreach (var comic in comiclst) { List <Chapter> cplst = cpq.Where(a => a.comicid == comic.comicid && a.source == Source.mh160).ToList(); if (cplst.Count == 0) { try { var bookdata = _helper.Get(comic.bookurl, Encoding.GetEncoding("gb2312")); bookdata = StringHelper.MergeSpace(bookdata); //string pattern = "<div class=\"plist pnormal\" id=\"play_0\"><li(?<key1>.*?)><a href=\"(?<key2>.*?)\" title=\"(?<key3>.*?)\" target=\"_blank\">(?<key4>.*?)</a></li>"; string pattern = "<div class=\"plist pnormal\" id=\"play_0\"> <ul>(?<key1>.*?)</ul> </div>"; MatchCollection matches = Regex.Matches(bookdata, pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); string pattern2 = "<a href=\"(?<key1>.*?)\" title=\"(?<key2>.*?)\" target=\"_blank\">(?<key3>.*?)</a>"; MatchCollection matches2 = Regex.Matches(matches[0].Groups["key1"].Value, pattern2, RegexOptions.IgnoreCase | RegexOptions.Singleline); for (int i = 0; i < matches2.Count; i++) { string chapterid = comic.comicid + "_" + matches2[i].Groups["key1"].Value.Split('/').LastOrDefault().Replace(".html", ""); string chaptername = matches2[i].Groups["key2"].Value; string chapterurl = "http://www.mh160.com" + matches2[i].Groups["key1"].Value; int sort = matches.Count - i; chapterlst.Add(new Chapter() { chapterid = chapterid, chaptername = chaptername, chapterurl = chapterurl, sort = sort, comicid = comic.comicid, retry = 0, source = comic.source, downstatus = DownChapter.待处理链接, isvip = "0", chaptersource = "", chapterlocal = "", modify = dt, shortdate = shortdate, }); } } catch (Exception ex) { logger.Error(ex.Message); comic.shortdate = shortdate; comic.modify = dt; dbcontext.Update(comic); Err_ChapterJob err = new Err_ChapterJob(); err.bookurl = comic.bookurl; err.source = comic.source; err.errtype = ErrChapter.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } } if (chapterlst.Count > 0) { dbcontext.BulkInsert(chapterlst); } }
public void Execute(IJobExecutionContext context) { HttpWebHelper _helper = new HttpWebHelper(); Dictionary <string, string> tags = new Dictionary <string, string>(); tags.Add("19", "日常"); tags.Add("20", "恋爱"); tags.Add("22", "奇幻"); tags.Add("23", "剧情"); tags.Add("24", "爆笑"); tags.Add("27", "治愈"); tags.Add("40", "完结"); tags.Add("41", "三次元"); tags.Add("46", "古风"); tags.Add("47", "校园"); tags.Add("48", "都市"); tags.Add("49", "少年"); tags.Add("52", "总裁"); tags.Add("53", "栏目"); tags.Add("54", "正能量"); tags.Add("56", "传统"); tags.Add("57", "日漫"); Dictionary <string, Comic> comicdic = new Dictionary <string, Comic>(); try { foreach (var tag in tags) { var t = _helper.Get <kuaikan_comic>($"http://www.kuaikanmanhua.com/web/tags/{tag.Key}?count=1800&page=0", Encoding.GetEncoding("utf-8")); var comiclst = new List <Comic>(); if (t.status_code == 200) { foreach (var topic in t.data.topics) { string comicid = "12_" + topic.id; if (!comicdic.ContainsKey(comicid)) { comicdic.Add(comicid, new Comic() { comicname = topic.title, authorname = topic.user == null ? "" : topic.user.nickname, bookurl = $"http://www.kuaikanmanhua.com/web/topic/{topic.id}/", comiccoversource = topic.vertical_image_url, comiccoverlocal = "", comicdesc = topic.description, comicid = "12_" + topic.id, isfinished = topic.description.Substring(topic.description.IndexOf('【') + 1).Split('/')[1].Contains("更新")? "连载中" : "已完结", theme = tag.Value, isvip = "0", source = 12, stopcrawer = false, isoffline = false, recrawer = false, shortdate = DateTime.Now.ToDateStr(), modify = DateTime.Now, comicsort = null, hot = topic.likes, copyright = topic.description.Substring(topic.description.IndexOf('【') + 1).Split('/')[0], }); } } } } var t2 = _helper.Get <kuaikan_comic>($"http://www.kuaikanmanhua.com/web/tags/0?count=1800&page=0", Encoding.GetEncoding("utf-8")); var comiclst2 = new List <Comic>(); if (t2.status_code == 200) { int sort = 0; foreach (var topic in t2.data.topics) { sort = sort + 1; comiclst2.Add(new Comic() { comicname = topic.title, authorname = topic.user == null ? "" : topic.user.nickname, bookurl = $"http://www.kuaikanmanhua.com/web/topic/{topic.id}/", comiccoversource = topic.vertical_image_url, comiccoverlocal = "", comicdesc = topic.description, comicid = "12_" + topic.id, isfinished = "连载中", theme = "", isvip = "0", source = 12, stopcrawer = false, isoffline = false, recrawer = false, shortdate = DateTime.Now.ToDateStr(), modify = DateTime.Now, comicsort = sort, hot = topic.likes }); } } foreach (var item in comicdic) { var comic = comiclst2.Where(x => x.comicid == item.Key).FirstOrDefault(); if (comic != null) { item.Value.comicsort = comic.comicsort; } } List <Comic> addlst = new List <Comic>(); foreach (var item in comicdic) { addlst.Add(item.Value); } service.ComicCompareBatchAdd(addlst, 12, DateTime.Now.ToDateStr()); } catch (Exception ex) { _logger.Error("Job_Comic 执行过程中发生异常:" + ex.ToString()); } finally { _logger.InfoFormat("Job_Comic Execute end "); } }
public void Execute(IJobExecutionContext context) { var comiclst = new List <Comic>(); HttpWebHelper _helper = new HttpWebHelper(); DateTime dt = DateTime.Now; string shortdate = dt.ToDateStr(); var web = new HtmlWeb(); var t = _helper.Get <wangyi_comic>("https://manhua.163.com/category/getData.json?csrfToken=d56b46d665fd2a53ed222d302a572718&sort=2&pageSize=72&page=1", Encoding.GetEncoding("utf-8")); int pagecount = t.pageQuery.pageCount; int sort = 0; if (pagecount > 0) { for (int i = 1; i <= pagecount; i++) { var booklst = _helper.Get <wangyi_comic>($"https://manhua.163.com/category/getData.json?csrfToken=d56b46d665fd2a53ed222d302a572718&sort=2&pageSize=72&page={i}", Encoding.GetEncoding("utf-8")); foreach (var bk in booklst.books) { try { sort = sort + 1; string bookurl = $"https://manhua.163.com/source/{bk.bookId}"; var doc = web.Load(bookurl); var meta = doc.DocumentNode.SelectSingleNode("//meta[@name=\"keywords\"]"); var arry = meta.Attributes["content"].Value.Split(',').ToList(); string comicname = arry[0]; string authorname = arry[arry.Count - 2]; arry.Remove(arry[0]); arry.Remove(arry[0]); arry.Remove(arry[arry.Count - 1]); arry.Remove(arry[arry.Count - 1]); string theme = string.Join(",", arry.Where(x => x.Length == 2).ToArray()); string comiccover = doc.DocumentNode.SelectSingleNode("//img[@class=\"sr-bcover\"]").Attributes["src"].Value; string bookdesc = doc.DocumentNode.SelectSingleNode("//dl[@class=\"sr-dl multi-lines j-desc-inner\"]").SelectSingleNode(".//dd").InnerText.Trim(); string isfinished = doc.DocumentNode.SelectSingleNode("//dl[@class=\"sr-dl\"]").SelectSingleNode(".//a").InnerText.Trim() == "连载中" ? "连载中" : "已完结"; comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = 6 + "_" + bk.bookId, isfinished = isfinished, theme = theme, isvip = "0", source = 6, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, comicsort = sort, hot = bk.clickCount }); } catch (Exception ex) { continue; } } } service.ComicCompareBatchAdd(comiclst, 6, DateTime.Now.ToDateStr()); } }
public void Execute(IJobExecutionContext context) { var comiclst = new List <Comic>(); HttpWebHelper _helper = new HttpWebHelper(); DateTime dt = DateTime.Now; string shortdate = dt.ToDateStr(); var jarraystr = _helper.Get("http://www.zymk.cn/app_api/v3/getallcomic/?callback=siftinit", Encoding.GetEncoding("utf-8")); jarraystr = jarraystr.Substring(jarraystr.IndexOf("[["), jarraystr.IndexOf("]]") - jarraystr.IndexOf("[[") + 2); var booklst = JsonHelper.DeserializeJsonToList <object>(jarraystr); foreach (var book in booklst) { var m = JArray.Parse(book.ToJson()); try { if (m[4].ToString().Contains(",28") || m[4].ToString().Contains(",51") || m[4].ToString().Contains(",30") || m[4].ToString().Contains(",52")) { string bookurl = $"http://www.zymk.cn/{m[0]}/"; var bookdata = _helper.Get(bookurl, Encoding.GetEncoding("utf-8")); Regex reg1 = new Regex("<meta property=\"og:novel:book_name\" content=\"(?<key1>.*?)\">"); Match match1 = reg1.Match(bookdata); string comicname = match1.Groups["key1"].Value; Regex reg2 = new Regex("<meta property=\"og:novel:author\" content=\"(?<key1>.*?)\">"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg3 = new Regex("<meta property=\"og:image\" content=\"(?<key1>.*?)\">"); Match match3 = reg3.Match(bookdata); string comiccover = match3.Groups["key1"].Value; Regex reg4 = new Regex("<div class=\"desc-con\">(?<key1>.*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim(); Regex reg5 = new Regex("<meta property=\"og:novel:status\" content=\"(?<key1>.*?)\">"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value == "连载" ? "连载中" : "已完结"; string theme = ""; Regex reg6 = new Regex("<meta property=\"og:novel:category\" content=\"(?<key1>.*?)\">"); Match match6 = reg6.Match(bookdata); theme = string.Join(",", match6.Groups["key1"].Value.Trim().Split(' ')); comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = 4 + "_" + bookurl.Split('/')[3], isfinished = isfinished, theme = theme, isvip = "0", source = 4, stopcrawer = false, isoffline = true, recrawer = false, shortdate = shortdate, modify = dt, comicsort = 0, comicsort2 = double.Parse(m[6].ToString()), hot = m[6].ToString() }); } } catch (Exception ex) { continue; } } comiclst = comiclst.OrderBy(x => x.comicsort2).ToList(); int sort = 0; comiclst.ForEach(x => { sort = sort + 1; x.comicsort = sort; }); service.ComicCompareBatchAdd(comiclst, 4, DateTime.Now.ToDateStr()); }
public void Execute(IJobExecutionContext context) { //string keystr = "meyJjb21pYyI6eyJpZCI6NTM4NzQzLCJ0aXRsZSI6Ilx1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A2YjEyODRkNzY1Mzc0Nl8xNTEwNTM3OTM3NDY2LmpwZ1wvMCIsInVybCI6Imh0dHA6XC9cL2FjLnFxLmNvbVwvQ29taWNWaWV3XC9pbmRleFwvaWRcLzYyNjg1MFwvY2lkXC8yIiwid2lkdGgiOiI2NTAiLCJoZWlnaHQiOiIxMTAifX0sImFydGlzdCI6eyJhdmF0YXIiOiJodHRwOlwvXC9xNC5xbG9nby5jblwvZz9iPXFxJms9d2g1c0ZOazAzUDV6RmlhOGljdGQ4ZW13JnM9NjQwJnQ9MTQ4MzMzOTY3NSIsIm5pY2siOiJcdTc3ZTVcdTk3ZjNcdTc5ZmJcdTUyYThcdTY1NzBcdTViNTciLCJ1aW5DcnlwdCI6IlVUSk1kVkpCZDAxTlFrSkVibGhzWmpOWlJqRjBaejA5In19"; //var ss = DecodeHelper.QQPageDecode(keystr.Substring(1)); //var tt = JsonHelper.DeserializeJsonToObject<QQ_Page_Api>(ss); //var redis = new RedisProxy(); //try //{ // redis.HashSet("QQ_Chapter", "185158", "185157"); //} //catch (Exception ex) //{ // throw; //} //var login_key = redis.Get<QQ_Login_Key>("QQ_1434299101"); DateTime dt = DateTime.Now; string ticks = dt.Ticks.ToString(); string shortdate = dt.ToString("yyyy-MM-dd"); string yesterday = dt.AddDays(-1).ToString("yyyy-MM-dd"); IQuery <Chapter> cpq = dbcontext.Query <Chapter>();//x.comicid == "1_622585" IQuery <VIPFreeComic> vfcq = dbcontext.Query <VIPFreeComic>(); List <Chapter> cplst; if (QQChapterTotal > 0) { cplst = cpq.Where(x => x.source == Source.QQ && x.downstatus == DownChapter.待处理链接 && x.isvip == "0" && x.Id % QQChapterTotal == QQChapterIndex).Take(200).ToList(); } else { cplst = cpq.Where(x => x.source == Source.QQ && x.downstatus == DownChapter.待处理链接 && x.isvip == "0").Take(200).ToList(); } List <int> ids = cplst.Select(x => x.Id).ToList(); dbcontext.Update <Chapter>(a => ids.Contains(a.Id), a => new Chapter() { ticks = ticks, downstatus = DownChapter.处理完链接, modify = dt }); List <Chapter> chapterlst = new List <Chapter>(); foreach (var cp in cplst) { try { //Dictionary<string, string> headers = new Dictionary<string, string>() //{ // {"Cookie","uin=o1434299101; skey="+login_key.skey+";" } //}; var imgdata = _helper.Get(cp.chapterurl, Encoding.GetEncoding("UTF-8"), null, "", null, "", null, "application/x-www-form-urlencoded; charset=UTF-8"); Regex rex = new Regex("var DATA = '(?<key1>.*?)',"); Match match = rex.Match(imgdata); string key = match.Groups["key1"].Value; if (string.IsNullOrEmpty(key)) { cp.downstatus = DownChapter.待处理链接; cp.modify = dt; cp.ticks = ticks; dbcontext.Update(cp); Err_ChapterJob err = new Err_ChapterJob(); err.bookurl = cp.chapterurl; err.source = cp.source; err.errtype = ErrChapter.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = "DATA解析失败"; err = dbcontext.Insert(err); continue; } var s = DecodeHelper.QQPageDecode(key.Substring(1)); var t = JsonHelper.DeserializeJsonToObject <QQ_Page_Api>(s); if (t.chapter.canRead) { List <Page> pglst = new List <Page>(); for (int i = 0; i < t.picture.Count; i++) { pglst.Add(new Page() { chapterid = cp.chapterid, modify = dt, shortdate = shortdate, sort = i + 1, source = cp.source, pagelocal = "", ticks = ticks, pagesource = t.picture[i].url }); } cp.isvip = "0"; cp.ticks = ticks; cp.downstatus = DownChapter.处理完链接; cp.modify = dt; dbcontext.Update(cp); dbcontext.BulkInsert(pglst); } else { List <VIPFreeComic> vfclst = vfcq.Where(x => x.source == Source.QQ && x.comicid == cp.comicid).ToList(); cp.isvip = vfclst.Count == 0 ? "1" : "0"; cp.ticks = ticks; cp.downstatus = DownChapter.待处理链接; cp.modify = dt; dbcontext.Update(cp); } } catch (Exception ex) { cp.downstatus = DownChapter.待处理链接; cp.modify = dt; cp.ticks = ticks; dbcontext.Update(cp); Err_ChapterJob err = new Err_ChapterJob(); err.bookurl = cp.chapterurl; err.source = cp.source; err.errtype = ErrChapter.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } }
public void Execute(IJobExecutionContext context) { //List<bkIm> bklst = ExcelHelper.Import(@"C:\Users\Administrator\Desktop\7家书单抓取.xlsx").ToList(); //List<bkIm> bklst = ExcelHelper.Import2(@"C:\Users\Administrator\Desktop\漫画抓取信息.xlsx").ToList(); List <bkIm> bklst = new List <bkIm>(); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628520" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627844" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627229" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626970" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626968" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626920" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626916" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626652" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626455" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624495" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624347" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624308" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624012" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623715" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623595" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623115" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622968" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622674" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622498" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/621673" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/621253" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/620523" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/620493" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553632" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553579" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553055" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/552920" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/552918" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/552839" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/552104" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/547900" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/547343" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/545168" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/544521" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/543172" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/542724" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/539105" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/536658" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628956" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628566" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628481" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628198" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628180" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628109" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627912" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627383" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627300" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627019" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626907" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626527" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626362" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624871" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624601" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623795" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623201" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623200" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623199" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623196" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623195" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622985" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622973" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622971" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622754" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622694" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622561" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622160" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/621727" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/621051" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/620725" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553972" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628458" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553644" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553026" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/552065" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/551693" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/551405" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/551386" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549847" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549277" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/548731" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/547243" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/545320" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/542861" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/538969" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/537982" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/534826" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/534796" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/534422" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/533555" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/533395" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/529810" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/518008" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/512742" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626289" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626269" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622660" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553518" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553204" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549673" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549599" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/545131" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/537899" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628565" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628464" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628428" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628305" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/628269" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627823" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/627456" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626955" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626819" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626604" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626465" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626268" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/626267" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624341" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624152" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624135" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/624009" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623833" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623720" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623494" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623492" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623459" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623283" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623125" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/623009" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622887" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622856" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622855" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622854" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622565" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622365" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622216" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/622108" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/621020" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/620928" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/553939" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/550484" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549278" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549274" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/549125" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/547358" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/545404" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/541345" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/540523" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/539443" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/536042" }); bklst.Add(new bkIm() { bookurl = "http://ac.qq.com/Comic/comicInfo/id/535934" }); //IQuery<VIPFreeComic> vfcq = dbcontext.Query<VIPFreeComic>(); //List<VIPFreeComic> vfclst = vfcq.Where(x => true).ToList(); //vfclst.ForEach(x => //{ // bklst.Add(new bkIm() // { // bookurl = x.bookurl // }); //}); List <Comic> comiclst = new List <Comic>(); IQuery <Comic> cq = dbcontext.Query <Comic>(); DateTime dt = DateTime.Now; string shortdate = dt.ToString("yyyy-MM-dd"); foreach (var bk in bklst) { if (!bk.bookurl.StartsWith("http://ac.qq.com")) { continue; } var comic = cq.Where(x => x.bookurl == bk.bookurl).FirstOrDefault(); if (comic != null) { continue; } if (bk.bookurl.StartsWith("http://ac.qq.com")) { try { HttpHelper _helper = new HttpHelper("http://ac.qq.com"); string bookurl = bk.bookurl.Replace("http://ac.qq.com/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("id=\"input_artistName\" value=\"(?<key1>.*?)\""); Match match1 = reg1.Match(bookdata); string authorname = match1.Groups["key1"].Value; Regex reg2 = new Regex("img src=\"(?<key1>.*?)\" alt=\"(?<key2>.*?)\" height=\"280\" width=\"210\""); Match match2 = reg2.Match(bookdata); string comiccover = match2.Groups["key1"].Value; string comicname = match2.Groups["key2"].Value; Regex reg3 = new Regex("<label class=\"works-intro-status\">(?<key1>.*?)</label>"); Match match3 = reg3.Match(bookdata); string isfinished = match3.Groups["key1"].Value; Regex reg4 = new Regex("<meta name=\"Description\" content=\"(?<key1>.*?),简介:(?<key2>.*?)《(?<key3>.*?)》的标签:(?<key4>.*?)\" />"); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key2"].Value; string theme = match4.Groups["key4"].Value; comiclst.Add(new Comic() { authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.QQ + "_" + bk.bookurl.Split('/').LastOrDefault(), comicname = comicname, isfinished = isfinished, theme = theme, isvip = "0", source = Source.QQ, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("https://www.dongmanmanhua.cn")) { try { HttpHelper _helper = new HttpHelper("https://www.dongmanmanhua.cn"); string bookurl = bk.bookurl.Replace("https://www.dongmanmanhua.cn/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("<meta property=\"og:image\" content=\"(?<key1>.*?)\" />"); Match match1 = reg1.Match(bookdata); string comiccover = match1.Groups["key1"].Value; Regex reg2 = new Regex("<meta property=\"com-dongman:webtoon:author\" content=\"(?<key1>.*?)\" />"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg3 = new Regex("<p class=\"summary\">(?<key1>.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match3 = reg3.Match(bookdata); string bookdesc = match3.Groups["key1"].Value; Regex reg4 = new Regex("<h1 class=\"subj\">(?<key1>.*?)</h1>"); Match match4 = reg4.Match(bookdata); string comicname = match4.Groups["key1"].Value; Regex reg5 = new Regex("txt_ico_up"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Length > 0 ? "连载中" : "已完结"; Regex reg6 = new Regex("<h2 class=\"genre(?<key1>.*?)\">(?<key2>.*?)</h2>"); Match match6 = reg6.Match(bookdata); string theme = match6.Groups["key2"].Value; comiclst.Add(new Comic() { authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.dongmanmanhua + "_" + bk.bookurl.Split('=').LastOrDefault(), comicname = comicname, isfinished = isfinished, theme = theme, isvip = "0", source = Source.dongmanmanhua, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("http://www.u17.com")) { try { HttpHelper _helper = new HttpHelper("http://www.u17.com"); string bookurl = bk.bookurl.Replace("http://www.u17.com/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("<title>(?<key1>.*?)</title>"); Match match1 = reg1.Match(bookdata); string comicname = match1.Groups["key1"].Value.Split('_')[0]; string authorname = match1.Groups["key1"].Value.Split('_')[1]; Regex reg2 = new Regex("cover_url = \"(?<key1>.*?)\""); Match match2 = reg2.Match(bookdata); string comiccover = match2.Groups["key1"].Value; Regex reg3 = new Regex("id=\"words\">(?<key1>.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match3 = reg3.Match(bookdata); string bookdesc = match3.Groups["key1"].Value.Trim(); Regex reg4 = new Regex("状态:(?<key1>.*?)<span(?<key2>.*?)>(?<key3>.*?)</span>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string isfinished = match4.Groups["key3"].Value.Trim(); Regex reg5 = new Regex("txt_ico_up"); Match match5 = reg5.Match(bookdata); string theme = ""; string pattern = "class=\"label(?<key1>.*?)\" title=\"(?<key3>.*?)\">(?<key2>.*?)</a>"; MatchCollection match6 = Regex.Matches(bookdata, pattern); if (match6.Count == 0) { pattern = "class=\"(?<key1>.*?)_tag \" id=\"tag_(?<key3>.*?)\">(?<key2>.*?)</a>"; match6 = Regex.Matches(bookdata, pattern); } for (int j = 0; j < match6.Count; j++) { if (j == 0) { theme = match6[j].Groups["key2"].Value.Trim(); } else { theme = theme + "," + match6[j].Groups["key2"].Value.Trim(); } } comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.U17 + "_" + bk.bookurl.Split('/').LastOrDefault().Replace(".html", ""), isfinished = isfinished, theme = theme, isvip = "0", source = Source.U17, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("http://www.zymk.cn")) { try { HttpHelper _helper = new HttpHelper("http://www.zymk.cn"); string bookurl = bk.bookurl.Replace("http://www.zymk.cn/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("<meta property=\"og:novel:book_name\" content=\"(?<key1>.*?)\">"); Match match1 = reg1.Match(bookdata); string comicname = match1.Groups["key1"].Value; Regex reg2 = new Regex("<meta property=\"og:novel:author\" content=\"(?<key1>.*?)\">"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg3 = new Regex("<meta property=\"og:image\" content=\"(?<key1>.*?)\">"); Match match3 = reg3.Match(bookdata); string comiccover = match3.Groups["key1"].Value; Regex reg4 = new Regex("<div class=\"desc-con\">(?<key1>.*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim(); Regex reg5 = new Regex("<meta property=\"og:novel:status\" content=\"(?<key1>.*?)\">"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value == "连载" ? "连载中" : "已完结"; string theme = ""; Regex reg6 = new Regex("<meta property=\"og:novel:category\" content=\"(?<key1>.*?)\">"); Match match6 = reg6.Match(bookdata); theme = string.Join(",", match6.Groups["key1"].Value.Trim().Split(' ')); comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.Zymk + "_" + bk.bookurl.Split('/')[3], isfinished = isfinished, theme = theme, isvip = "0", source = Source.Zymk, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("http://www.manhuatai.com")) { try { HttpHelper _helper = new HttpHelper("http://www.manhuatai.com"); string bookurl = bk.bookurl.Replace("http://www.manhuatai.com/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("<meta property=\"og:novel:book_name\" content=\"(?<key1>.*?)\">"); Match match1 = reg1.Match(bookdata); string comicname = match1.Groups["key1"].Value; Regex reg2 = new Regex("<meta property=\"og:novel:author\" content=\"(?<key1>.*?)\">"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg3 = new Regex("<meta property=\"og:image\" content=\"(?<key1>.*?)\">"); Match match3 = reg3.Match(bookdata); string comiccover = match3.Groups["key1"].Value; Regex reg4 = new Regex("<div class=\"wz clearfix t1\"><div>(?<key1>.*?)<a href=\"javascript:void(?<key2>.*?)\" target=\"_self\" class=\"wzrtitle\" onclick=\"openOrCloseSummary", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim(); Regex reg5 = new Regex("<meta property=\"og:novel:status\" content=\"(?<key1>.*?)\">"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value == "连载中" ? "连载中" : "已完结"; string theme = ""; Regex reg6 = new Regex("<meta property=\"og:novel:category\" content=\"(?<key1>.*?)\">"); Match match6 = reg6.Match(bookdata); theme = string.Join(",", match6.Groups["key1"].Value.Trim().Split(' ')); comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.Manhuatai + "_" + bk.bookurl.Split('/')[3], isfinished = isfinished, theme = theme, isvip = "0", source = Source.Manhuatai, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("https://manhua.163.com")) { try { HttpHelper _helper = new HttpHelper("https://manhua.163.com"); string bookurl = bk.bookurl.Replace("https://manhua.163.com/", ""); var bookdata = _helper.Get(null, bookurl); Regex reg1 = new Regex("<meta name=\"keywords\" content=\"(?<key1>.*?)\">"); Match match1 = reg1.Match(bookdata); var arry = match1.Groups["key1"].Value.Split(',').ToList(); string comicname = arry[0]; string authorname = arry[arry.Count - 2]; arry.Remove(arry[0]); arry.Remove(arry[0]); arry.Remove(arry[arry.Count - 1]); arry.Remove(arry[arry.Count - 1]); string theme = string.Join(",", arry.Where(x => x.Length == 2).ToArray()); Regex reg3 = new Regex("<img class=\"sr-bcover\" src=\"(?<key1>.*?)\"/>"); Match match3 = reg3.Match(bookdata); string comiccover = match3.Groups["key1"].Value; Regex reg4 = new Regex("<dt>简介</dt>(?<key2>.*?)<dd>(?<key1>.*?)</dd>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim(); Regex reg5 = new Regex("<dt>状态</dt>(?<key2>.*?)<dd><a href=\"(?<key3>.*?)\" target=\"_blank\">(?<key1>.*?)</a></dd>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value == "连载中" ? "连载中" : "已完结"; comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source._163 + "_" + bk.bookurl.Split('/')[4], isfinished = isfinished, theme = theme, isvip = "0", source = Source._163, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } else if (bk.bookurl.StartsWith("http://www.mh160.com")) { try { HttpWebHelper _helper = new HttpWebHelper(); var bookdata = _helper.Get(bk.bookurl, Encoding.GetEncoding("gb2312")); Regex reg1 = new Regex("<meta property=\"og:novel:book_name\" content=\"(?<key1>.*?)\">"); Match match1 = reg1.Match(bookdata); string comicname = match1.Groups["key1"].Value; Regex reg2 = new Regex("<meta property=\"og:novel:author\" content=\"(?<key1>.*?)\">"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg3 = new Regex("<meta property=\"og:image\" content=\"(?<key1>.*?)\">"); Match match3 = reg3.Match(bookdata); string comiccover = match3.Groups["key1"].Value; Regex reg4 = new Regex("<div class=\"introduction\" id=\"intro1\"><p>(?<key1>.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim(); Regex reg5 = new Regex("<meta property=\"og:novel:status\" content=\"(?<key1>.*?)\">"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value == "连载中" ? "连载中" : "已完结"; string theme = ""; Regex reg6 = new Regex("<meta property=\"og:novel:category\" content=\"(?<key1>.*?)\">"); Match match6 = reg6.Match(bookdata); theme = string.Join(",", match6.Groups["key1"].Value.Trim().Split(' ')); comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bk.bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = (int)Source.mh160 + "_" + bk.bookurl.Split('/')[4], isfinished = isfinished, theme = theme, isvip = "0", source = Source.mh160, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, }); } catch (Exception ex) { logger.Error(ex.Message); Err_ComicJob err = new Err_ComicJob(); err.bookurl = bk.bookurl; err.errtype = ErrComic.解析出错; err.modify = dt; err.shortdate = shortdate; err.message = ex.Message; err = dbcontext.Insert(err); continue; } } } if (comiclst.Count > 0) { //foreach (var item in comiclst) //{ // var comic = cq.Where(x => x.bookurl == item.bookurl).FirstOrDefault(); // comic.comicdesc = item.comicdesc; // dbcontext.Update(comic); //} dbcontext.BulkInsert(comiclst); } }
public void Execute(IJobExecutionContext context) { List <Comic> comiclst = new List <Comic>(); DateTime dt = DateTime.Now; string shortdate = dt.ToDateStr(); int pageindex = 0; var web = new HtmlWeb(); int sort = 0; while (true) { pageindex = pageindex + 1; var doc = web.Load($"http://www.manhuatai.com/all_p{pageindex}.html"); var alst = doc.DocumentNode.SelectNodes("//a[@class=\"sdiv\"]"); foreach (var a in alst) { try { sort = sort + 1; string bookurl = "http://www.manhuatai.com" + a.Attributes["href"].Value; var data = web.Load(bookurl); var comicname = data.DocumentNode.SelectSingleNode("//meta[@property=\"og:novel:book_name\"]").Attributes["content"].Value; var authorname = data.DocumentNode.SelectSingleNode("//meta[@property=\"og:novel:author\"]").Attributes["content"].Value; var comiccover = data.DocumentNode.SelectSingleNode("//meta[@property=\"og:image\"]").Attributes["content"].Value; var bookdesc = data.DocumentNode.SelectSingleNode("//div[@class=\"wz clearfix t1\"]").InnerText.Trim(); var isfinished = data.DocumentNode.SelectSingleNode("//meta[@property=\"og:novel:status\"]").Attributes["content"].Value == "连载中" ? "连载中" : "已完结"; var theme = data.DocumentNode.SelectSingleNode("//meta[@property=\"og:novel:category\"]").Attributes["content"].Value.Replace(" ", ","); HttpWebHelper ht = new HttpWebHelper(); var numres = ht.Get($"http://api.share.baidu.com/getnum?url=http://www.manhuatai.com{a.Attributes["href"].Value}&callback=bdShare.fn._getShare&type=load", Encoding.GetEncoding("utf-8")); numres = numres.Split(',').Last().Replace("]})", "").Replace("\"", "").Replace("\\", "").Trim(); if (numres.IndexOf('u') > 0) { numres = numres.Substring(0, numres.IndexOf('u')) + StringHelper.UnicodeToString(numres.Substring(numres.IndexOf('u'))); } comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = 5 + "_" + bookurl.Split('/')[3], isfinished = isfinished, theme = theme, isvip = "0", source = 5, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, comicsort = sort, hot = numres }); } catch (Exception ex) { continue; } } if (pageindex > 1 && doc.DocumentNode.SelectNodes("//a[@class=\"page nolink\"]") != null) { break; } } service.ComicCompareBatchAdd(comiclst, 5, DateTime.Now.ToDateStr()); }
public void Execute(IJobExecutionContext context) { try { int pagecount = 0; int sort = 0; DateTime dt = DateTime.Now; string shortdate = dt.ToString("yyyy-MM-dd"); List <Comic> comiclst = new List <Comic>(); while (true) { HttpWebHelper _helper = new HttpWebHelper(); pagecount = pagecount + 1; string bookurl = $"http://m.zhangyue.com/search/more?keyWord=%E6%BC%AB%E7%94%BB¤tPage={pagecount}"; var data = _helper.Get <zhangyue_comic_api>(bookurl, Encoding.GetEncoding("utf-8")); if (data.html.IsNullOrWhiteSpace()) { break; } string pattern2 = "<a href=\"(?<key1>.*?)\" data-js=\"pointBook\">"; MatchCollection matches2 = Regex.Matches(data.html, pattern2); for (int j = 0; j < matches2.Count; j++) { try { var bookdetailurl = matches2[j].Groups["key1"].Value; var bookdata = _helper.Get(bookdetailurl, Encoding.GetEncoding("utf-8")); Regex reg1 = new Regex("<img class=\"bookcover\" data-js=\"book\" src=\"(?<key1>.*?)\" alt=\"(?<key2>.*?)\">"); Match match1 = reg1.Match(bookdata); string comiccover = match1.Groups["key1"].Value; string comicname = match1.Groups["key2"].Value; Regex reg2 = new Regex("<span class=\"it red\">(?<key1>.*?)</span>"); Match match2 = reg2.Match(bookdata); string authorname = match2.Groups["key1"].Value; Regex reg4 = new Regex("<p data-js=\"brief_intro_txt\">(?<key1>.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match4 = reg4.Match(bookdata); string bookdesc = match4.Groups["key1"].Value.Trim().Replace("内容简介:", ""); Regex reg5 = new Regex("<dd class=\"lastline\"><span>(?<key1>.*?)</span></dd>"); Match match5 = reg5.Match(bookdata); string isfinished = match5.Groups["key1"].Value.Contains("连载中") ? "连载中" : "已完结"; string pattern = "<span data-js=\"goCategory\" data-id=\"(?<key2>.*?)\" data-url=\"(?<key3>.*?)\">(?<key1>.*?)</span>"; MatchCollection matches = Regex.Matches(bookdata, pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); string theme = ""; List <string> themelst = new List <string>(); for (int i = 0; i < matches.Count; i++) { themelst.Add(matches[i].Groups["key1"].Value.Trim()); } theme = string.Join(",", themelst); Regex reg6 = new Regex("<span class=\"yellow\">(?<key1>.*?)</span>"); Match match6 = reg6.Match(bookdata); Regex reg7 = new Regex("<span class=\"f10\">(?<key2>.*?)</span>"); Match match7 = reg7.Match(bookdata); string renqi = match6.Groups["key1"].Value + " | " + match7.Groups["key2"].Value; sort = sort + 1; comiclst.Add(new Comic() { comicname = comicname, authorname = authorname, bookurl = bookdetailurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = "11" + "_" + bookdetailurl.Split('/')[4].Replace(".html", ""), isfinished = isfinished, theme = theme, isvip = "0", source = 11, stopcrawer = true, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, comicsort = sort, hot = renqi, area = "", isdelete = false, updatedatetime = "" }); } catch (Exception ex) { continue; } } } service.ComicCompareBatchAdd(comiclst, 11, DateTime.Now.ToDateStr()); } catch (Exception ex) { ; } }
public void Execute(IJobExecutionContext context) { string errMsg = string.Empty; IList <IWebElement> frames = selenium.FindElements(By.TagName("iframe")); IWebElement controlPanelFrame = null; foreach (var frame in frames) { if (frame.GetAttribute("id") == "login_ifr") { controlPanelFrame = frame; break; } } if (controlPanelFrame != null && controlPanelFrame.Displayed == true) { try { selenium.SwitchTo().Frame(controlPanelFrame); IReadOnlyCollection <IWebElement> switchtoElement = selenium.FindElements(By.Id("switcher_plogin")); if (switchtoElement != null && switchtoElement.Count > 0 && switchtoElement.First().Displayed == true) { switchtoElement.First().Click(); //selenium.FindElement(By.Id("u")).Clear(); //selenium.FindElement(By.Id("u")).SendKeys("3283360259"); //selenium.FindElement(By.Id("p")).Clear(); //selenium.FindElement(By.Id("p")).SendKeys("xxxttt5544"); selenium.FindElement(By.Id("u")).Clear(); selenium.FindElement(By.Id("u")).SendKeys("1434299101"); selenium.FindElement(By.Id("p")).Clear(); selenium.FindElement(By.Id("p")).SendKeys("zhangyin123"); selenium.FindElement(By.Id("login_button")).Click(); } selenium.SwitchTo().DefaultContent(); ICookieJar listCookie = selenium.Manage().Cookies; string uin = listCookie.AllCookies.Where(x => x.Name == "uin").FirstOrDefault().Value; string skey = listCookie.AllCookies.Where(x => x.Name == "skey").FirstOrDefault().Value; string pc_userinfo_cookie = HttpUtility.UrlDecode(listCookie.AllCookies.Where(x => x.Name == "pc_userinfo_cookie").FirstOrDefault().Value); Regex reg1 = new Regex("token\":\"(?<key1>.*?)\"", RegexOptions.IgnoreCase | RegexOptions.Singleline); Match match1 = reg1.Match(pc_userinfo_cookie); string token = match1.Groups["key1"].Value; var rs = _helper.Get("http://106.75.31.146/Cache/QQ_Login_Cache?skey=" + skey + "&token=" + token, Encoding.GetEncoding("UTF-8"), null, "", null, "", null, "application/x-www-form-urlencoded; charset=UTF-8"); //var redis = new RedisProxy(); //redis.Set("QQ_1434299101", new QQ_Login_Key() //{ // skey = skey, // token = token //}); //redis.Add("QQ_1434299101", new QQ_Login_Key() //{ // skey = skey, // token = token //}); } catch (Exception ex) { errMsg = "QQ 登录失败:" + ex.Message; logger.Error(errMsg); } } }
public void Execute(IJobExecutionContext context) { List <Comic> comiclst = new List <Comic>(); DateTime dt = DateTime.Now; string shortdate = dt.ToDateStr(); var web = new HtmlWeb(); var doc = web.Load("https://www.dongmanmanhua.cn/genre"); Dictionary <string, string> dic = new Dictionary <string, string>(); List <string> bkids = new List <string>(); var lis = doc.DocumentNode.SelectNodes("//li[@data-title-no]"); foreach (var li in lis) { var alink = "https:" + li.SelectSingleNode(".//a").Attributes["href"].Value; if (!dic.ContainsKey(alink)) { dic.Add(alink, alink); bkids.Add(alink.Split('=').Last().Trim()); } } int sort = 0; HttpWebHelper ht = new HttpWebHelper(); var res = ht.Get <webtoons_comic>("https://www.dongmanmanhua.cn/v1/title/like/count?titleNos=" + string.Join(",", bkids.ToArray()), Encoding.GetEncoding("utf-8")); foreach (var item in dic) { try { sort = sort + 1; string bookurl = item.Value; var detail = web.Load(bookurl); string comiccover = detail.DocumentNode.SelectSingleNode("//meta[@property=\"og:image\"]").Attributes["content"].Value; string authorname = detail.DocumentNode.SelectSingleNode("//meta[@property=\"com-dongman:webtoon:author\"]").Attributes["content"].Value; string bookdesc = detail.DocumentNode.SelectSingleNode("//p[@class=\"summary\"]").InnerText.Trim(); string comicname = detail.DocumentNode.SelectSingleNode("//h1[@class=\"subj\"]").InnerText.Trim(); string isfinished = detail.DocumentNode.SelectNodes("//span[@class=\"txt_ico_up\"]") != null? "连载中" : "已完结"; string theme = detail.DocumentNode.SelectSingleNode("//h2[contains(@class,'genre')]").InnerText.Trim(); comiclst.Add(new Comic() { authorname = authorname, bookurl = bookurl, comiccoversource = comiccover, comiccoverlocal = "", comicdesc = bookdesc, comicid = 2 + "_" + bookurl.Split('=').LastOrDefault(), comicname = comicname, isfinished = isfinished, theme = theme, isvip = "0", source = 2, stopcrawer = false, isoffline = false, recrawer = false, shortdate = shortdate, modify = dt, comicsort = sort, hot = res.data.Where(x => x.titleNo == item.Value.Split('=').Last().Trim()).First().count.ToString() }); } catch (Exception ex) { continue; } } service.ComicCompareBatchAdd(comiclst, 2, DateTime.Now.ToDateStr()); }