Exemple #1
0
        public void run(string key, Button btn)
        {
            //Thread.Sleep(5000);
            //MessageBox.Show(key);
            DataGridView c = this.Controls.Find(key, true)[0] as DataGridView;
            //MessageBox.Show(c.Rows.Count.ToString());
            DataTable dt = ((DataTable)(SOURCES[key]["回"]));

            for (int i = 0, max_i = c.Rows.Count; i < max_i; i++)
            {
                //下載單頁
                Console.WriteLine(my.json_encode(dt.Rows[i]));
                Dictionary <string, object> d = new Dictionary <string, object>();
                //From : https://stackoverflow.com/questions/15049877/getting-webbrowser-cookies-to-log-in
                //https://stackoverflow.com/questions/9048922/c-sharp-invalidcastexception-when-trying-to-access-webbrowser-control-from-tim
                //d["webBrowser"] = getBrowser();
                //wB.Url = new System.Uri(dt.Rows[i]["URL"].ToString(), System.UriKind.Absolute);
                //Thread.Sleep(500);
                //d["cookie_domain"] = wBDomain;
                //d["cookie_data"] = wBCookie;
                string data = my.b2s(my.file_get_contents_post(dt.Rows[i]["URL"].ToString(), "", d));
                //取得漫畫照片範圍
                data = my.get_between(data, "var cmnData = ", "</script>");
                data = data.Trim();
                //移除最後一個;
                if (data.Substring(data.Length - 1, 1) == ";")
                {
                    data = data.Substring(0, data.Length - 1);
                }
                data  = data.Trim();
                data += "3WA超強";
                data  = my.get_between(data, "imageData:", "}3WA超強");
                var pics = my.json_decode(data);

                WebBrowser newWB = getBrowser();
                TabPage    tp    = tabControl1.TabPages[key];
                //newWB.Location = new Point(500, 0);
                //newWB.Width = 1024;
                //newWB.Height = 768;
                //tp.Controls.Add(newWB);
                //copyControl(wB, newWB);
                newWB.Url = new System.Uri(dt.Rows[i]["URL"].ToString(), System.UriKind.Absolute);
                newWB.WebBrowserShortcutsEnabled = true;
                //newWB.ScriptErrorsSuppressed = false;


                newWB.ScriptErrorsSuppressed = true;


                Func <string, string> Eval = (script) =>
                {
                    return(newWB.Document.InvokeScript("eval", new string[] {
                        "(function() { return " + script + "; })()"
                    }).ToString());
                };
                Func <string, string> runSC = (script) =>
                {
                    try
                    {
                        return(newWB.Document.InvokeScript("eval", new string[] {
                            "(function() { " + script + " })()"
                        }).ToString());
                    }
                    catch
                    {
                        return("");
                    }
                };

                newWB.DocumentCompleted -= wB_DocumentCompleted;
                newWB.DocumentCompleted += wB_DocumentCompleted;

                //感覺不適合下載圖
                break;
                for (int j = 0, max_j = pics[0].Count(); j < max_j; j++)
                {
                    Console.WriteLine("PIC[0][" + j.ToString() + "]: " + pics[0][j].ToString());
                    string expires = my.get_between(pics[0][j].ToString(), "Expires=", "&");
                    pics[0][j]         = pics[0][j].ToString().Replace(expires, (Convert.ToInt64(my.time()) + 2).ToString());
                    d["cookie_domain"] = ".comico.com.tw";
                    wBCookie           = wBCookie.Replace("appier_pv_counterqvJaMzdQzyXvi7N=8", "appier_pv_counterqvJaMzdQzyXvi7N=1");
                    wBCookie           = wBCookie.Replace("appier_pv_counterTw501dpRLjrYXae=7", "appier_pv_counterTw501dpRLjrYXae=1");
                    d["cookie_data"]   = wBCookie;
                    d["referer"]       = dt.Rows[i]["URL"].ToString();
                    d["headers"]       = new List <string>();
                    d["accept"]        = "image/webp,*/*";
                    ((List <string>)(d["headers"])).Add("TE: Trailers");
                    //((List<string>)(d["headers"])).Add("Accept: image/webp,*/*");
                    ((List <string>)(d["headers"])).Add("Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3");
                    ((List <string>)(d["headers"])).Add("Accept-Encoding: gzip, deflate, br");
                    byte[] p = my.file_get_contents_post(pics[0][j].ToString(), "", d);
                    my.file_put_contents(PWD + "\\" + j + ".png", p);
                    Array.Clear(p, 0, p.Length);
                    break;
                }
                //my.file_put_contents(PWD + "\\ok.txt", data);
                break;
            }

            //finish
            UpdateUIText("開始下載", btn);
        }
Exemple #2
0
        private void tabControl1_Click(object sender, EventArgs e)
        {
            //Console.WriteLine(tabControl1.SelectedTab.Name);
            switch (tabControl1.SelectedTab.Name)
            {
            case "tabs_host":
                //本機資訊
                log("本機資訊");
                //threads["tabs_host"] = new Thread(() => cSystem.init(this));
                //threads["tabs_host"].Start();
                if (cSystem.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cSystem.last_date) >= 5 * 60)
                {
                    cSystem.init(this);
                }
                break;

            case "tabs_hdd":
                //讀硬碟的
                log("硬碟");
                if (cHdd.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cHdd.last_date) >= 5 * 60)
                {
                    cHdd.init(this);
                }
                break;

            case "tabs_running_program":
                //執行緒
                log("執行緒");
                if (cRunningProgram.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cRunningProgram.last_date) >= 5 * 60)
                {
                    cRunningProgram.init(this);
                }
                break;

            case "tabs_schedule":
                //排程
                log("排程");
                if (cSchedule.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cSchedule.last_date) >= 5 * 60)
                {
                    cSchedule.init(this);
                }
                break;

            case "tabs_service":
                //服務
                log("服務");
                if (cSystemService.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cSystemService.last_date) >= 5 * 60)
                {
                    cSystemService.init(this);
                }
                break;

            case "tabs_firewall":
                //防火牆
                log("防火牆");
                if (cFirewall.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cFirewall.last_date) >= 5 * 60)
                {
                    cFirewall.init(this);
                }
                break;

            case "tabs_events":
                //events
                log("事件");
                if (cEvents.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cEvents.last_date) >= 5 * 60)
                {
                    cEvents.init(this);
                }
                break;

            case "tabs_IIS":
                //IIS
                log("IIS");
                if (cIis.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cIis.last_date) >= 5 * 60)
                {
                    cIis.init(this);
                }
                break;

            case "tabs_installed_program":
            {
                log("已安裝的程式");
                if (cInstalledSoftware.last_date == "" || Convert.ToInt32(my.time()) - Convert.ToInt32(cInstalledSoftware.last_date) >= 5 * 60)
                {
                    cInstalledSoftware.init(this);
                }
            }
            break;
            }
        }