private void fetchImgFromContentPage(string pageUrl, string picIndex) { string cookies = string.Empty; string myPageHtml = MyHttp.getHtml(pageUrl, out cookies);//获取图片url列表 //string[] imgUrl = MyWebsiteConverter.imgReg(myPageHtml);//获取图片url string[] imgUrl = WebSiteConverter.imgReg(myPageHtml, ws.imgKeys); for (int i = 0; i < imgUrl.Length; i++) { if (imgUrl[i].StartsWith("//")) { imgUrl[i] = "http:" + imgUrl[i]; } else if (!imgUrl[i].StartsWith("http")) { imgUrl[i] = domain + imgUrl[i]; } } string myTitle = MyHttp.getValidFileName(MyHttp.getHtmlTitle(myPageHtml));//获取合法标题 if (imgUrl.Length > 0) { myWriteLine("Fetch Page Successful:Index[" + picIndex + "]Title:" + myTitle); lock (addListLocker) { ImgInfo tmpImgInfo = new ImgInfo(imgUrl, myTitle, picIndex, new MyHttp.httpParameter(cookies, "", pageUrl)); fetchPageCount++; //计算获取页面数 fetchImgCount += imgUrl.Length; //计算获取图片数 OnPageFetched(null, new OnFetchedEventArgs(tmpImgInfo)); } } else { myWriteLine("Fetch Page Invalid:Index[" + picIndex + "]Title:" + myTitle, ConsoleColor.Red); } }
private void previewButton_Click(object sender, EventArgs e) { WebSiteSetting ws = WebsiteInfo.websiteList.Find(s => s.siteName == siteComboBox.Text); //System.Diagnostics.Process.Start(ws.websiteConverter.urlConvert(urlTextBox.Text, imgTypeTextBox.Text, 1)); string myUrl = WebSiteConverter.getUrl(urlPatTextBox.Text, _1stUrlTextBox.Text, urlTextBox.Text, imgTypeTextBox.Text, 1); System.Diagnostics.Process.Start(myUrl); }
private string[] fetchContentPageUrl(string domain, string imgType, long pageIndex) { //string myUrl = MyWebsiteConverter.urlConvert(domain, imgType, pageIndex); //得出url string myUrl = WebSiteConverter.getUrl(ws.urlPattern, ws.firstPageUrlPattern, ws.domain, ws.imgType, pageIndex); string myHtml = MyHttp.getHtml(myUrl, out cookies); //获取html //string[] myContentPageUrl = MyWebsiteConverter.pageReg(myHtml); //获取页面链接 string[] myContentPageUrl = WebSiteConverter.pageReg(myHtml, ws.pageRegex); return(myContentPageUrl); }