//public bool ShowExplicit { get; set; } //public virtual bool IsSupportCount { get { return true; } } //public virtual bool IsSupportScore { get { return true; } } //public virtual bool IsSupportRes { get { return true; } } //public virtual bool IsSupportPreview { get { return true; } } //public virtual bool IsSupportJpeg { get { return true; } } //public virtual bool IsSupportTag { get { return true; } } //public virtual System.Drawing.Point LargeImgSize { get { return new System.Drawing.Point(SWIDTH, SWIDTH); } } //public virtual System.Drawing.Point SmallImgSize { get { return new System.Drawing.Point(SWIDTH, SHEIGHT); } } /// <summary> /// get images sync /// </summary> //public virtual List<Img> GetImages(int page, int count, string keyWord, int maskScore, int maskRes, ViewedID lastViewed, bool maskViewed, System.Net.IWebProxy proxy, bool showExplicit) //{ // return GetImages(GetPageString(page, count, keyWord, proxy), maskScore, maskRes, lastViewed, maskViewed, proxy, showExplicit); //} public override string GetPageString(int page, int count, string keyWord, System.Net.IWebProxy proxy) { string url = string.Format(siteUrl, needMinus ? page - 1 : page, count, keyWord); if (keyWord.Length == 0) { url = url.Substring(0, url.Length - 6); } /* * System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); * req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; * req.Proxy = proxy; * req.Timeout = 8000; * req.Method = "GET"; * req.ReadWriteTimeout = 8000; * req.KeepAlive = true; * req.UseDefaultCredentials = true; * //prevent 303 See Other * req.AllowAutoRedirect = true; * System.Net.WebResponse rsp = req.GetResponse(); */ MoeLoader.MyWebClient web = new MoeLoader.MyWebClient(); web.Proxy = proxy; web.Encoding = Encoding.UTF8; //Debug.WriteLine("======>DownloadString ==========>" + url); url = "https://yande.re/"; string pageString = web.DownloadString(url); web.Dispose(); return(pageString); }
/// <summary> /// Retrieve informations in the remote file AutoupdateService.xml /// <?xml version="1.0" encoding="utf-8"?> /// <Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> /// <LocalFile app = "Karaboss" url="http://ds.lacharme.net/pub/karaboss1.0.1.1-setup.exe" lastver="1.0.1.2" size="933136" needRestart="true" /> /// </Config> /// </summary> /// <param name="xml"></param> /// <returns></returns> private Dictionary <string, RemoteFile> ParseRemoteXml(string xml) { Dictionary <string, RemoteFile> list = new Dictionary <string, RemoteFile>(); try { XmlTextReader rd; HttpWebRequest wrq; wrq = (HttpWebRequest)WebRequest.Create(xml); System.Net.IWebProxy iwpxy = WebRequest.GetSystemWebProxy(); wrq.Proxy = iwpxy; wrq.Proxy.Credentials = CredentialCache.DefaultCredentials; rd = new XmlTextReader(wrq.GetResponse().GetResponseStream()); XmlDocument document = new XmlDocument(); document.Load(xml); foreach (XmlNode node in document.DocumentElement.ChildNodes) { list.Add(node.Attributes["app"].Value, new RemoteFile(node)); } } catch (Exception err) { Console.Write(err.Message); string tx = "Error when trying to load remote file: " + xml + "\n"; tx += err.Message; MessageBox.Show(tx); } return(list); }
private static Image DownloadImage(string imageUrl, System.Net.IWebProxy proxy) { Image image = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imageUrl); request.AllowWriteStreamBuffering = true; request.Proxy = proxy; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); image = Image.FromStream(responseStream); responseStream.Close(); response.Close(); } catch (Exception ex) { throw new GSearchException("Unable to download image", ex); } return(image); }
public override List <MoeLoader.TagItem> GetTags(string word, System.Net.IWebProxy proxy) { List <MoeLoader.TagItem> re = new List <MoeLoader.TagItem>(); string url = string.Format(tagUrl, 8, word); MoeLoader.MyWebClient web = new MoeLoader.MyWebClient(); web.Timeout = 8; web.Proxy = proxy; web.Encoding = Encoding.UTF8; string xml = web.DownloadString(url); //<?xml version="1.0" encoding="UTF-8"?> //<tags type="array"> // <tag type="3" ambiguous="false" count="955" name="neon_genesis_evangelion" id="270"/> // <tag type="3" ambiguous="false" count="335" name="angel_beats!" id="26272"/> // <tag type="3" ambiguous="false" count="214" name="galaxy_angel" id="243"/> // <tag type="3" ambiguous="false" count="58" name="wrestle_angels_survivor_2" id="34664"/> //</tags> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml.ToString()); XmlElement root = (XmlElement)(xmlDoc.SelectSingleNode("tags")); //root foreach (XmlNode node in root.ChildNodes) { XmlElement tag = (XmlElement)node; string name = tag.GetAttribute("name"); string count = tag.GetAttribute("count"); re.Add(new MoeLoader.TagItem() { Name = name, Count = count }); } return(re); }
public void TryCreate_DoesNotCreateNonCredentialsPluginTwice() { var uri = new Uri("https://api.nuget.org/v3/index.json"); var authUsername = "******"; var authPassword = "******"; var expectation = new TestExpectation( serviceIndexJson: null, sourceUri: null, operationClaims: new[] { OperationClaim.DownloadPackage }, connectionOptions: ConnectionOptions.CreateDefault(), pluginVersion: ProtocolConstants.CurrentVersion, uri: uri, authenticationUsername: authUsername, authenticationPassword: authPassword, success: false ); using (var test = new PluginManagerMock( pluginFilePath: "a", pluginFileState: PluginFileState.Valid, expectations: expectation)) { var discoveryResult = new PluginDiscoveryResult(new PluginFile("a", new Lazy <PluginFileState>(() => PluginFileState.Valid))); var provider = new SecurePluginCredentialProvider(test.PluginManager, discoveryResult, NullLogger.Instance); System.Net.IWebProxy proxy = null; var credType = CredentialRequestType.Unauthorized; var message = "nothing"; var isRetry = false; var isInteractive = false; var token = CancellationToken.None; var credentialResponse = provider.GetAsync(uri, proxy, credType, message, isRetry, isInteractive, token).Result; Assert.True(credentialResponse.Status == CredentialStatus.ProviderNotApplicable); Assert.Null(credentialResponse.Credentials); var credentialResponse2 = provider.GetAsync(uri, proxy, credType, message, isRetry, isInteractive, token).Result; Assert.True(credentialResponse2.Status == CredentialStatus.ProviderNotApplicable); Assert.Null(credentialResponse2.Credentials); } }
public override List <Img> GetImages(string pageString, System.Net.IWebProxy proxy) { List <Img> list = new List <Img>(); HtmlDocument dococument = new HtmlDocument(); dococument.LoadHtml(pageString); HtmlNodeCollection imageItems = dococument.DocumentNode.SelectNodes("//*[@class='image-list cl']"); if (imageItems == null) { return(list); } foreach (HtmlNode imageItem in imageItems) { HtmlNode imgNode = imageItem.SelectSingleNode("./div[1]/img"); string detailUrl = SiteUrl + imgNode.Attributes["data-href"].Value; string tags = imgNode.Attributes["alt"].Value; int id = StringToInt(imgNode.Attributes["id"].Value); Img item = new Img() { Height = Convert.ToInt32(imageItem.SelectSingleNode("//div[@class='image']").Attributes["data-height"].Value), Width = Convert.ToInt32(imageItem.SelectSingleNode("//div[@class='image']").Attributes["data-width"].Value), IsExplicit = false, Tags = tags, Desc = tags, PreviewUrl = imgNode.Attributes["data-original"].Value, Id = id, DetailUrl = detailUrl }; item.DownloadDetail = (i, p) => { //string html = new MyWebClient { Proxy = p, Encoding = Encoding.UTF8 }.DownloadString(i.DetailUrl); //HtmlDocument doc = new HtmlDocument(); //doc.LoadHtml(html); }; list.Add(item); } return(list); }
public override string GetPageString(int page, int count, string keyWord, System.Net.IWebProxy proxy) { Login(proxy); //http://yuriimg.com/post/?.html string url = SiteUrl + "/post/" + page + ".html"; // string url = "http://yuriimg.com/show/ge407xd5o.jpg"; MyWebClient web = new MyWebClient(); web.Proxy = proxy; web.Encoding = Encoding.UTF8; if (keyWord.Length > 0) { //http://yuriimg.com/search/index/tags/?/p/?.html url = SiteUrl + "/search/index/tags/" + keyWord + "/p/" + page + ".html"; } string pageString = web.DownloadString(url); web.Dispose(); return(pageString); }
public override List <MoeLoader.Img> GetImages(string pageString, System.Net.IWebProxy proxy) { MoeLoader.BooruProcessor nowSession = new MoeLoader.BooruProcessor(srcType); return(nowSession.ProcessPage(siteUrl, pageString)); }
void IDataLoader.SetProxy(System.Net.IWebProxy proxy) { this.SetProxy(proxy); }
internal void SetProxy(System.Net.IWebProxy proxy) { Proxy = proxy; }
// string _fiddlerOverrideGateway; /// <summary> /// コンストラクタ /// </summary> /// <param name="bPortable">設定を保存しない時true</param> public FormMain(bool bPortable) { InitializeComponent(); IntPtr ptr = Handle; _bPortable = bPortable; MouseWheel += FormMain_MouseWheel; MouseEnter += FormMain_MouseEnter; _sysProxy = System.Net.WebRequest.DefaultWebProxy; var asm = System.Reflection.Assembly.GetExecutingAssembly(); imageListSlotItemType.Images.AddStrip(new Bitmap( asm.GetManifestResourceStream("KCB2.SlotItemsSmallIcon.bmp"))); imageListSlotItemType.TransparentColor = Color.FromArgb(255, 0, 255); deckMemberList.SlotItemIconImageList = imageListSlotItemType; #if RESTORE_VOLUME ///起動時の音量設定を覚えておく using (var mixer = new MixerAPI()) { bootVol = mixer.Volume; bootMute = mixer.Mute; } #endif // WebRequestの同時処理数を引き上げる if (ServicePointManager.DefaultConnectionLimit < 20) { Debug.WriteLine(string.Format("ServicePointManager.DefaultConnectionLimit {0} -> 20", ServicePointManager.DefaultConnectionLimit)); ServicePointManager.DefaultConnectionLimit = 20; } //スレッドプール数を増やす int minWorkerThread, minCompletionPortThread; ThreadPool.GetMinThreads(out minWorkerThread, out minCompletionPortThread); Debug.WriteLine(string.Format("ManagedThread minWorkder:{0} minCompPortThread:{1}", minWorkerThread, minCompletionPortThread)); if (minWorkerThread < 20) { Debug.WriteLine(string.Format("minWorkerThread {0} -> 20", minWorkerThread)); ThreadPool.SetMinThreads(20, minCompletionPortThread); } _httProxy = new HTTProxy(); _httProxy.BeforeRequest += new HTTProxy.HTTProxyCallbackHandler(_httProxy_BeforeRequest); _httProxy.AfterSessionCompleted += new HTTProxy.HTTProxyCallbackHandler(_httProxy_AfterSessionCompleted); ///過去の設定を引っ張ってる場合。 if (Properties.Settings.Default.ProxyPort <= 0) Properties.Settings.Default.ProxyPort = 8088; _gsWrapper = new GSpread.SpreadSheetWrapper(); if (!_httProxy.Start(Properties.Settings.Default.ProxyPort)) MessageBox.Show("HttpListenerの起動に失敗しました。情報は取得されません。\n設定を確認してください"); else UpdateProxyConfiguration(); _logManager = new LogManager.LogManager(this); // _fiddlerOverrideGateway = Properties.Settings.Default.FiddlerOverrideGateway; #if !DEBUG if (Properties.Settings.Default.UseDevMenu) #endif { _watchSession = true; _logLastJSON = new RingBuffer<JSONData>(Properties.Settings.Default.SkipbackJSON+1); } deckMemberList.UpdateDeckStatus = UpdateDeckConditionTime; ///縦横切替を使うかどうか switchViewModeToolStripMenuItem.Visible = false; setLogStore(); }
/// <summary> /// get images sync /// </summary> //public List<Img> GetImages(int page, int count, string keyWord, int maskScore, int maskRes, ViewedID lastViewed, bool maskViewed, System.Net.IWebProxy proxy, bool showExplicit) //{ // return GetImages(GetPageString(page, count, keyWord, proxy), maskScore, maskRes, lastViewed, maskViewed, proxy, showExplicit); //} public override string GetPageString(int page, int count, string keyWord, System.Net.IWebProxy proxy) { Login(proxy); //http://gallery.minitokyo.net/scans?order=id&display=extensive&page=2 string url = "http://gallery.minitokyo.net/" + type + "?order=id&display=extensive&page=" + page; MyWebClient web = new MyWebClient(); web.Proxy = proxy; web.Headers["Cookie"] = sessionId; web.Encoding = Encoding.UTF8; if (keyWord.Length > 0) { //先使用关键词搜索,然后HTTP 303返回实际地址 //http://www.minitokyo.net/search?q=haruhi url = SiteUrl + "/search?q=" + keyWord; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"; req.Proxy = proxy; req.Timeout = 8000; req.Method = "GET"; //prevent 303 See Other req.AllowAutoRedirect = false; WebResponse rsp = req.GetResponse(); //http://www.minitokyo.net/Haruhi+Suzumiya //HTTP 303然后返回实际地址 string location = rsp.Headers["Location"]; rsp.Close(); if (location != null && location.Length > 0) { //非完整地址,需要前缀 url = SiteUrl + location; //再次访问,得到真实列表页地址... string html = web.DownloadString(url); //http://browse.minitokyo.net/gallery?tid=2112&index=1 WALL //http://browse.minitokyo.net/gallery?tid=2112&index=3 SCAN //http://browse.minitokyo.net/gallery?tid=2112&index=1&order=id int urlIndex = html.IndexOf("http://browse.minitokyo.net/gallery?tid="); if (type == WALL) { url = html.Substring(urlIndex, html.IndexOf('"', urlIndex) - urlIndex - 1) + "1"; } else { url = html.Substring(urlIndex, html.IndexOf('"', urlIndex) - urlIndex - 1) + "3"; } //http://browse.minitokyo.net/gallery?tid=2112&%3Bindex=1&order=id&display=extensive url += "&order=id&display=extensive&page=" + page; url = url.Replace("&", "&"); } else { throw new Exception("搜索失败,请检查您输入的关键词"); } } string pageString = web.DownloadString(url); web.Dispose(); return(pageString); }
IClientBuilder IClientBuilder.SetProxy(System.Net.IWebProxy proxy) { this.proxy = proxy; return(this); }
private void ProcDownload(object o) { evtPerDonwload = new ManualResetEvent(false); if (downloadFileList != null) { total += downloadFileList.Size; } try { while (!evtDownload.WaitOne(0, false)) { if (downloadFileList == null) { break; } DownloadFileInfo file = downloadFileList; this.ShowCurrentDownloadFileName(file.FileName); //Download clientDownload = new WebClient(); //Added the function to support proxy System.Net.IWebProxy iwpxy = WebRequest.GetSystemWebProxy(); clientDownload.Proxy = iwpxy; //clientDownload.Proxy = WebProxy.GetDefaultProxy(); clientDownload.Proxy.Credentials = CredentialCache.DefaultCredentials; clientDownload.Credentials = System.Net.CredentialCache.DefaultCredentials; //End added // Progress changed clientDownload.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) => { try { this.SetProcessBar(e.ProgressPercentage, (int)((nDownloadedTotal + e.BytesReceived) * 100 / total)); } catch { //log the error message,you can use the application's log code } }; // Download completed clientDownload.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => { try { DownloadFileInfo dfile = e.UserState as DownloadFileInfo; nDownloadedTotal += dfile.Size; this.SetProcessBar(0, (int)(nDownloadedTotal * 100 / total)); evtPerDonwload.Set(); } catch (Exception) { //log the error message,you can use the application's log code } }; evtPerDonwload.Reset(); //Download // Telecharge le fichier dans le repertoire downloads clientDownload.DownloadFileAsync(new Uri(file.DownloadUrl), Path.Combine(file.TargetUrl, file.FileName), file); //Wait for the download complete evtPerDonwload.WaitOne(); clientDownload.Dispose(); clientDownload = null; downloadFileList = null; } } catch (Exception) { ShowErrorAndRestartApplication(); //throw; } //After dealed with all files, clear the data allFileList = null; if (downloadFileList == null) { Exit(true); } else { Exit(false); } evtDownload.Set(); }