Exemple #1
0
        public void OnBeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
        {
            //HtmlDocument doc = (HtmlDocument)explorer.Document;
            ////HtmlElementCollection body_content = doc.GetElementById("body");
            //HtmlElement dd = (HtmlElement)explorer.Document;
            //HtmlElementCollection body_content = dd.GetElementsByTagName("body");
            //doc.

            //doc.CreateElement(

            //if(URL.ToString().IndexOf("amazon.com")!=-1)
            //{
            //    Regex rg = new Regex("/^https?:\/\/\w+\.amazon\..+\/gp\/product\/([a-zA-Z0-9]{10})\/.*/");
            //    rg.IsMatch(URL.ToString());

            //    string ss = URL.ToString();
            //    MessageBox.Show(URL.ToString());
            //    //ShowBrowserBar(true);
            //}
            //else
            //{
            //    //ShowBrowserBar(false);
            //}
            if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/gp\/product\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("product/") + 8, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                String         strResponse = ri.GetResponse(webRequest);

                MessageBox.Show(strResponse);

                try
                {
                    HtmlDocument doc    = (HtmlDocument)explorer.Document;
                    HtmlElement  newdiv = doc.CreateElement("div");
                    newdiv.SetAttribute("id", "pluribo_div");
                    newdiv.InnerHtml = strResponse;
                    HtmlElementCollection body_contents = doc.GetElementsByTagName("body");
                    HtmlElement           body          = body_contents[0];
                    body.AppendChild(newdiv);
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/dp\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("dp/") + 3, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                String         strResponse = ri.GetResponse(webRequest);

                MessageBox.Show(strResponse);

                try
                {
                    HtmlDocument doc    = (HtmlDocument)explorer.Document;
                    HtmlElement  newdiv = doc.CreateElement("div");
                    newdiv.SetAttribute("id", "pluribo_div");
                    newdiv.InnerHtml = strResponse;
                    HtmlElementCollection body_contents = doc.GetElementsByTagName("body");
                    HtmlElement           body          = body_contents[0];
                    body.AppendChild(newdiv);
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/exec\/obidos\/ASIN\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("ASIN/") + 5, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                try
                {
                    HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                    String         strResponse = ri.GetResponse(webRequest);

                    MessageBox.Show(strResponse);
                    HtmlDocument doc    = (HtmlDocument)explorer.Document;
                    HtmlElement  newdiv = doc.CreateElement("div");
                    newdiv.SetAttribute("id", "pluribo_div");
                    newdiv.InnerHtml = strResponse;
                    HtmlElementCollection body_contents = doc.GetElementsByTagName("body");
                    HtmlElement           body          = body_contents[0];
                    body.AppendChild(newdiv);
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/review\/product\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("product/") + 8, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                String         strResponse = ri.GetResponse(webRequest);

                try
                {
                    MessageBox.Show(strResponse);
                    HtmlDocument doc    = (HtmlDocument)explorer.Document;
                    HtmlElement  newdiv = doc.CreateElement("div");
                    newdiv.SetAttribute("id", "pluribo_div");
                    newdiv.InnerHtml = strResponse;
                    HtmlElementCollection body_contents = doc.GetElementsByTagName("body");
                    HtmlElement           body          = body_contents[0];
                    body.AppendChild(newdiv);
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
        }
Exemple #2
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            //HtmlDocument doc = (HtmlDocument)explorer.Document;
            ////HtmlElementCollection body_content = doc.GetElementById("body");
            //HtmlElement dd = (HtmlElement)explorer.Document;
            //HtmlElementCollection body_content = dd.GetElementsByTagName("body");
            //doc.

            //doc.CreateElement(

            //if(URL.ToString().IndexOf("amazon.com")!=-1)
            //{
            //    Regex rg = new Regex("/^https?:\/\/\w+\.amazon\..+\/gp\/product\/([a-zA-Z0-9]{10})\/.*/");
            //    rg.IsMatch(URL.ToString());

            //    string ss = URL.ToString();
            //    MessageBox.Show(URL.ToString());
            //    //ShowBrowserBar(true);
            //}
            //else
            //{
            //    //ShowBrowserBar(false);
            //}
            //MessageBox.Show("Event fired - " + e.Url.ToString());
            if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/gp\/product\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("product/") + 8, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                //essageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                String         strResponse = ri.GetResponse(webRequest);


                try
                {
                    //MessageBox.Show(strResponse);

                    //IHTMLDocument2 doc = new HTMLDocumentClass();
                    //doc = (IHTMLDocument2)AxWebBrowser1.Document;

                    //foreach(IHTMLElement2 element in doc.all)
                    //{
                    //    //my processing goes here.

                    //}

                    //System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();


                    //mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)explorer.Document;


                    //HtmlDocument doc = (HtmlDocument)explorer.Document;
                    //HtmlElement newdiv = doc.CreateElement("div");

                    IHTMLDocument2 doc = new HTMLDocumentClass();
                    doc = (IHTMLDocument2)explorer.Document;
                    doc.body.innerHTML = strResponse + doc.body.innerHTML;


                    //doc = (IHTMLDocument2)explorer.Document;
                    //MessageBox.Show(doc.body.id);

                    //IHTMLElement newdiv = doc.createElement("div");
                    //newdiv.setAttribute("id", "pluribo_div", 1);

                    //IHTMLElement nnnn = new HTMLElementCollectionClass();
                    //nnnn = (IHTMLElement)doc.createElement("div");



                    //newdiv.SetAttribute("id", "pluribo_div");

                    //newdiv.innerHTML = strResponse;

                    //IHTMLDocument3 doc1 = new HTMLDocumentClass();
                    //doc1 = (IHTMLDocument3)explorer.Document;

                    //IHTMLElementCollection body_contents = doc1.getElementsByTagName("body");
                    //IHTMLElementCollection BODY_CONTENTS = new HTMLElementCollectionClass();
                    //BODY_CONTENTS = (IHTMLElementCollection)doc1.getElementsByTagName("body");
                    //IHTMLElement body = new HtmlElement();
                    //body = (IHTMLElement2)body_contents;

                    //IHTMLElement body =
                    //body.AppendChild(newdiv);
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    //MessageBox.Show("DONE!!!!","MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/dp\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();

                string ASIN_ID = new string(url_string.ToCharArray(url_string.IndexOf("dp/") + 3, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                //MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                String         strResponse = ri.GetResponse(webRequest);


                try
                {
                    //MessageBox.Show(strResponse);

                    IHTMLDocument2 doc = new HTMLDocumentClass();
                    doc = (IHTMLDocument2)explorer.Document;
                    doc.body.innerHTML = "<div id=\"pluribo_div\">" + strResponse + "</div>" + doc.body.innerHTML;
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    //MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/exec\/obidos\/ASIN\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("ASIN/") + 5, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                //MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();

                try
                {
                    //WebClient eb = new WebClient();
                    //String htmlcode = eb.DownloadString(url_string);

                    //MessageBox.Show(htmlcode);



                    //HtmlDocument doc = (HtmlDocument)explorer.Document;

                    HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                    String         strResponse = ri.GetResponse(webRequest);
                    //MessageBox.Show(strResponse);

                    IHTMLDocument2 doc = new HTMLDocumentClass();
                    doc = (IHTMLDocument2)explorer.Document;
                    doc.body.innerHTML = "<div id=\"pluribo_div\">" + strResponse + "</div>" + doc.body.innerHTML;

                    /*dsfasdfdsfs*/
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    //MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
            else if (Regex.IsMatch(URL.ToString(), @"^https?:\/\/\w+\.amazon\..+\/review\/product\/([a-zA-Z0-9]{10})\/.*"))
            {
                string url_string = URL.ToString();
                string ASIN_ID    = new string(url_string.ToCharArray(url_string.IndexOf("product/") + 8, 10));

                string PLID = "AZ" + ASIN_ID;

                string target_url = "http://pluribo.com/xhr/id/" + PLID + "/plugin";

                //MessageBox.Show(target_url);

                RestImpl ri = new RestImpl();
                IDictionary <String, String> paramList = new Dictionary <String, String>();


                try
                {
                    HttpWebRequest webRequest  = ri.CreateRequest(target_url, paramList);
                    String         strResponse = ri.GetResponse(webRequest);
                    //MessageBox.Show(strResponse);

                    IHTMLDocument2 doc = new HTMLDocumentClass();
                    doc = (IHTMLDocument2)explorer.Document;
                    doc.body.innerHTML = "<div id=\"pluribo_div\">" + strResponse + "</div>" + doc.body.innerHTML;
                }
                catch (Exception et)
                {
                    MessageBox.Show(et.ToString());
                }
                finally
                {
                    //MessageBox.Show("DONE!!!!", "MESSage");
                }
            }
        }