コード例 #1
0
        private void wb1_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            string[] SourceName = wb1.Source.ToString().Split(new char[] { '#', '/', '&', '=', ':', '?' }, StringSplitOptions.RemoveEmptyEntries);

            HTMLDocument doc = (HTMLDocument)wb1.Document;

            if (SourceName[6] == "page")
            {
                IHTMLElementCollection theElementCollection = doc.getElementsByName("email");
                foreach (IHTMLElement curElement in theElementCollection)
                {
                    curElement.setAttribute("value", Properties.Settings.Default.BotLogins[0]);
                }

                theElementCollection = doc.getElementsByName("pass");
                foreach (IHTMLElement curElement in theElementCollection)
                {
                    curElement.setAttribute("value", Properties.Settings.Default.BotPasswords[0]);
                    doc.getElementById("install_allow").click();
                }

                theElementCollection = doc.getElementsByClassName("flat_button fl_r button_indent");
                foreach (IHTMLElement curElement in theElementCollection)
                {
                    curElement.click();
                }
            }
            else if (SourceName[2] == "blank.html")
            {
                _token = SourceName[4];
                this.Close();
            }
        }
コード例 #2
0
 public void Run()
 {
     Thread.Sleep(300);
     Util.SetElementValue(doc.getElementsByName(AMOUNT_FIELD), info.AmountToPay.Replace(".", ","));
     Util.SetElementValue(doc.getElementsByName(TITLE_FIELD), parent.ReplaceSpecialChars(info.Title));
     Util.SetElementValue(doc.getElementsByName(DATE_FIELD), info.DueDateTimeToPaste.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
 }
コード例 #3
0
        protected override void PastePaymentInfo(PaymentRequest request)
        {
            HTMLDocument doc  = request.Document;
            PaymentInfo  info = request.PaymentInfo;

            if (info.IsDefinedTransfer == false)
            {
                IEnumerator e = doc.getElementsByTagName("input").GetEnumerator();
                while (e.MoveNext())
                {
                    IHTMLInputElement input = e.Current as IHTMLInputElement;
                    if ("AccountNumberFullDestinationInput".Equals((e.Current as IHTMLInputElement).value))
                    {
                        (e.Current as IHTMLElement).click();
                        break;
                    }
                }

                Util.SetElementValue(doc.getElementById(ACCOUNT_FIELD), info.BankAccountNo);
                Util.SetElementValue(doc.getElementById(NAME_FIELD), ReplaceSpecialChars(info.BillerName));
                Util.SetElementValue(doc.getElementById(ADDRESS_FIELD), ReplaceSpecialChars(info.Street));
                Util.SetElementValue(doc.getElementById(POSTAL_CODE_FIELD), ReplaceSpecialChars(info.PostalCodeAndCity));
            }
            Util.SetElementValue(doc.getElementById(DESCRIPTION_FIELD), ReplaceSpecialChars(info.Title));
            Util.SetElementValue(doc.getElementsByName(AMOUNT_INT_FIELD), info.AmountToPayDecimal);
            Util.SetElementValue(doc.getElementsByName(AMOUNT_DEC_FIELD), info.AmountToPayFloating);
            // real value is taken from hidden field
            Util.SetElementValue(doc.getElementById(AMOUNT_FIELD), info.AmountToPay.Replace(".", ","));
            Util.SetElementValue(doc.getElementsByName(YEAR_FIELD), info.DueDateTimeToPaste.Year.ToString());
            Util.SetElementValue(doc.getElementsByName(MONTH_FIELD), Util.GetMonth(info.DueDateTimeToPaste.Month));
            Util.SetElementValue(doc.getElementsByName(DAY_FIELD), info.DueDateTimeToPaste.Day.ToString());

            info.State = State.IN_PROGRESS;
        }
コード例 #4
0
        /// <summary>
        /// Pastes payment information in the transfer HTML form.
        /// </summary>
        /// <param name="request">payment request</param>
        protected override void PastePaymentInfo(PaymentRequest request)
        {
            HTMLDocument doc  = request.Document;
            PaymentInfo  info = request.PaymentInfo;

            Util.SetElementValue(doc.getElementById(ACCOUNT_FIELD), info.BankAccountNo);
            String[] billerName = Util.SplitString(ReplaceSpecialChars(info.BillerName), 35, BENEFICIARY_NAME_FIELD.Length);
            for (int i = 0; i < billerName.Length; i++)
            {
                Util.SetElementValue(doc.getElementsByName(BENEFICIARY_NAME_FIELD[i]), billerName[i]);
            }
            Util.SetElementValue(doc.getElementsByName(ADDRESS_1_FIELD), ReplaceSpecialChars(info.Street));
            Util.SetElementValue(doc.getElementsByName(ADDRESS_2_FIELD), ReplaceSpecialChars(info.PostalCodeAndCity));

            String[] title = Util.SplitString(ReplaceSpecialChars(info.Title), 35, TITLE_FIELD.Length);
            for (int i = 0; i < title.Length; i++)
            {
                Util.SetElementValue(doc.getElementsByName(TITLE_FIELD[i]), title[i]);
            }
            Util.SetElementValue(doc.getElementsByName(AMOUNT_1_FIELD), info.AmountToPayDecimal);
            Util.SetElementValue(doc.getElementsByName(AMOUNT_2_FIELD), info.AmountToPayFloating);
            Util.SetElementValue(doc.getElementsByName(YEAR_FIELD), info.DueDateTimeToPaste.Year.ToString());
            Util.SetElementValue(doc.getElementsByName(MONTH_FIELD), info.DueDateTimeToPaste.Month.ToString());
            Util.SetElementValue(doc.getElementsByName(DAY_FIELD), info.DueDateTimeToPaste.Day.ToString());

            info.State = State.IN_PROGRESS;
        }
コード例 #5
0
ファイル: WebAction.cs プロジェクト: Hong822/CS_KPMCreator
        public bool CallEvent(InternetExplorer IE, HTMLDocument doc, string ID, string EventType)
        {
            bool bResult = true;

#if (DEBUG)
            g_Util.DebugPrint("[CallEvent]" + ID + ", " + EventType);
#endif

            TotalWait(IE, doc, ID);
            IHTMLElementCollection SelectedElement = doc.getElementsByName(ID);

            foreach (IHTMLElement3 elem in SelectedElement)
            {
                try
                {
                    elem.FireEvent("onkeyup", null);
                }
                catch (System.Exception e)
                {
                    g_Util.DebugPrint("[Exception] " + e);
                    bResult = false;
                }
            }

            return(bResult);
        }
コード例 #6
0
ファイル: FrmMain.cs プロジェクト: arienx/BuyTickets
        private string GetTokenData()
        {
            HTMLDocument           html       = wbMain.Document.DomDocument as HTMLDocument;
            IHTMLElementCollection collection = html.getElementsByName(ORDERACTION_TOKENKEY);
            var result = (collection.item(0) as HTMLInputElementClass).value;

            return(result);
        }
コード例 #7
0
 public static void fillRadio(HTMLDocument document, string name, string value)
 {
     foreach (IHTMLInputElement radio in document.getElementsByName(name))
     {
         if (radio.value.Equals(value))
         {
             radio.@checked = true;
         }
     }
 }
コード例 #8
0
ファイル: WebAction.cs プロジェクト: Hong822/CS_KPMCreator
        private bool WaitUntilID(HTMLDocument doc, string ID, string ElemType = "ID")
        {
            bool bResult = true;
            int  nTimer  = 60;
            int  nTry    = 0;

            if (ElemType == "ID")
            {
                while (nTry < nTimer)
                {
                    if (doc.getElementById(ID) == null)
                    {
                        nTry++;
#if (DEBUG)
                        g_Util.DebugPrint("Wait ID = " + ID);
#endif
                        System.Threading.Thread.Sleep(1000);
                        bResult = false;
                    }
                    else
                    {
#if (DEBUG)
                        g_Util.DebugPrint("Find ID = " + ID);
#endif
                        bResult = true;
                        break;
                    }
                }
            }
            else if (ElemType == "NAME")
            {
                while (nTry < nTimer)
                {
                    if (doc.getElementsByName(ID) == null)
                    {
                        nTry++;
#if (DEBUG)
                        g_Util.DebugPrint("Wait ID = " + ID);
#endif
                        System.Threading.Thread.Sleep(1000);
                        bResult = false;
                    }
                    else
                    {
#if (DEBUG)
                        g_Util.DebugPrint("Find ID = " + ID);
#endif
                        bResult = true;
                        break;
                    }
                }
            }

            return(bResult);
        }
コード例 #9
0
 public void OnAuthorizationRequest(HTMLDocument document)
 {
     try
     {
         _login    = document.getElementById(LoginId).getAttribute(InputValue).ToString() !;
         _password = ((IHTMLElement)document.getElementsByName(PasswordClass).item())
                     .getAttribute(InputValue).ToString() !;
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
     }
 }
コード例 #10
0
        protected override void PastePaymentInfo(PaymentRequest request)
        {
            HTMLDocument doc  = request.Document;
            PaymentInfo  info = request.PaymentInfo;

            if (info.IsDefinedTransfer == false)
            {
                if (IsAnyTransferSelected(doc) == false)
                {
                    GoToTransferPage(request);
                    return;
                }
                Util.SetElementValue(doc.getElementsByName(ACCOUNT_FIELD), info.BankAccountNo);
                if (info.BillerName.Length > 32)
                {
                    Util.SetElementValue(doc.getElementsByName(NAME_FIELD), ReplaceSpecialChars(info.BillerName).Substring(0, 32));
                }
                else
                {
                    Util.SetElementValue(doc.getElementsByName(NAME_FIELD), ReplaceSpecialChars(info.BillerName));
                }
                Util.SetElementValue(doc.getElementsByName(STREET_FIELD), ReplaceSpecialChars(info.Street));
                Util.SetElementValue(doc.getElementsByName(CITY_FIELD), ReplaceSpecialChars(info.City));
                Util.SetElementValue(doc.getElementsByName(POSTAL_CODE_FIELD), info.PostalCode);
            }
            else
            {
                Object tmp    = null;
                int    result = Util.SetElementValue(doc.getElementsByName(DEFINED_TRANSFER_FIELD), info.DefinedTransferName, doc.CreateEventObject(ref tmp));
                if (result == -1)
                {
                    String question = String.Format(Resources.BzWbkNoDefinedTransfer, info.DefinedTransferName);
                    if (Util.ShowYesNoQuestion(null, question) == true)
                    {
                        info.DefinedTransferName = "";
                        PastePaymentInfo(request);
                    }
                    else
                    {
                        info.State = State.INVALID;
                    }
                    return;
                }
                else if (result > 1)
                {
                    Util.ShowInfoMessage(String.Format(Resources.BzWbkMoreThanOneDefinedTransfer, info.DefinedTransferName));
                }
            }
            // we have to wait 300ms and paste data asynchronously because some
            // ugly JavaScript clears all the fields on the bank's page
            new Thread(new ThreadStart(new PasteHelper(request, this).Run)).Start();

            info.State = State.IN_PROGRESS;
        }
コード例 #11
0
        protected override bool ReadyToPaste(PaymentRequest request)
        {
            HTMLDocument doc = request.Document;

            if (request.PaymentInfo.IsDefinedTransfer == false && doc.getElementsByName(ANY_TRANSFER_FORM).length > 0)
            {
                IHTMLElement field = doc.getElementsByName(DESTINATION_ACCOUNT_FIELD).item(DESTINATION_ACCOUNT_FIELD, 0) as IHTMLElement;
                return(field != null && "text".Equals(field.getAttribute("type", 1)));
            }
            else if (request.PaymentInfo.IsDefinedTransfer && doc.getElementsByName(DEFINED_TRANSFER_FORM).length > 0)
            {
                if (doc.getElementsByName(DESTINATION_ACCOUNT_FIELD).length == 0)
                {
                    IHTMLElement field = doc.getElementsByName(DESCRIPTION_FIELD).item(DESCRIPTION_FIELD, 0) as IHTMLElement;
                    if (field != null && "textarea".Equals(field.getAttribute("type", 1)))
                    {
                        return(IsDefinedTransferPage(request));
                    }
                }
            }
            return(false);
        }
コード例 #12
0
ファイル: IeDocument.cs プロジェクト: hbschmidt/IeRobot
        public List <IeElement> GetElementsByName(string value)
        {
            var result = new List <IeElement>();

            var elements = Document.getElementsByName(value);

            foreach (IHTMLElement element in elements)
            {
                result.Add(new IeElement(element));
            }

            return(result);
        }
コード例 #13
0
ファイル: WebAction.cs プロジェクト: Hong822/CS_KPMCreator
        public bool ClickButton(InternetExplorer IE, HTMLDocument doc, string ID, string ElemType = "ID")
        {
            bool bResult = true;

#if (DEBUG)
            g_Util.DebugPrint("[ClickButton]" + ID);
#endif
            if (TotalWait(IE, doc, ID, ElemType) == false)
            {
                if (ElemType != "NAME")
                {
                    g_Util.DebugPrint("Element Waiting False. Skip this action.  " + ID);
                    return(true);
                }
            }

            if (ElemType == "ID" || ElemType == null)
            {
                IHTMLElement SelectedElement = doc.getElementById(ID);
                try
                {
                    SelectedElement.click();
                }
                catch (System.Exception e)
                {
                    g_Util.DebugPrint("Problem happen" + e);
                    bResult = false;
                }
            }
            else if (ElemType == "NAME")
            {
                IHTMLElementCollection SelectedElement = doc.getElementsByName(ID);

                foreach (IHTMLElement elem in SelectedElement)
                {
                    try
                    {
                        elem.click();
                        break;
                    }
                    catch (System.Exception e)
                    {
                        g_Util.DebugPrint("[Exception] " + e);
                        bResult = false;
                    }
                }
            }

            return(bResult);
        }
コード例 #14
0
 public void clickByName(string name)
 {
     Application.Current.Dispatcher.Invoke((() =>
     {
         HTMLDocument doc = webbrowser.Document as HTMLDocument;
         IHTMLElementCollection e = doc.getElementsByName(name);
         if (e != null)
         {
             foreach (IHTMLElement el in e)
             {
                 el.click();
             }
         }
     }));
 }
コード例 #15
0
 public void SetValueByName(string id, string value)
 {
     Application.Current.Dispatcher.Invoke((() =>
     {
         HTMLDocument doc = webbrowser.Document as HTMLDocument;
         IHTMLElementCollection e = doc.getElementsByName(id);
         if (e != null)
         {
             foreach (IHTMLElement el in e)
             {
                 el.setAttribute("value", value);
             }
         }
     }));
 }
コード例 #16
0
        protected override void PastePaymentInfo(PaymentRequest request)
        {
            PaymentInfo  info = request.PaymentInfo;
            HTMLDocument doc  = request.Document;

            Util.SetElementValue(doc.getElementsByName(AMOUNT_A_FIELD), info.AmountToPayDecimal);
            Util.SetElementValue(doc.getElementsByName(AMOUNT_B_FIELD), info.AmountToPayFloating);
            Util.SetElementValue(doc.getElementsByName(DESCRIPTION_FIELD), ReplaceSpecialChars(info.Title));
            if (info.IsDefinedTransfer == false)
            {
                Util.SetElementValue(doc.getElementsByName(DESTINATION_ACCOUNT_FIELD), info.BankAccountNo);
                Util.SetElementValue(doc.getElementsByName(BENEFICIARY_NAME_FIELD), ReplaceSpecialChars(info.BillerName));
                Util.SetElementValue(doc.getElementsByName(STREET_FIELD), ReplaceSpecialChars(info.Street));
                Util.SetElementValue(doc.getElementsByName(CITY_FIELD), ReplaceSpecialChars(info.City));
                Util.SetElementValue(doc.getElementsByName(POSTAL_CODE_FIELD), info.PostalCode);
            }
            info.State = State.IN_PROGRESS;
        }
コード例 #17
0
        public static void FillSelectByName(HTMLDocument document, string name, string value, string converted, bool fireOnchange = false)
        {
            if (null == name || "".Equals(name))
            {
                return;
            }

            IHTMLElementCollection collection = (IHTMLElementCollection)document.getElementsByName(name);

            if (null != collection && collection.length > 0)
            {
                foreach (IHTMLElement element in collection)
                {
                    if (element is IHTMLSelectElement)
                    {
                        FillSelect((IHTMLSelectElement)element, value, converted, fireOnchange);
                    }
                }
            }
        }
コード例 #18
0
        public static void FillTextByName(HTMLDocument document, string name, string value)
        {
            if (null == name || "".Equals(name))
            {
                return;
            }

            IHTMLElementCollection collection = (IHTMLElementCollection)document.getElementsByName(name);

            if (null != collection && collection.length > 0)
            {
                foreach (IHTMLElement element in collection)
                {
                    if (element is IHTMLInputElement)
                    {
                        ((IHTMLInputElement)element).value = null == value ? "" : value;
                    }
                }
            }
        }
コード例 #19
0
        protected override bool ReadyToPaste(PaymentRequest request)
        {
            HTMLDocument doc = request.Document;
            IEnumerator  e   = doc.getElementsByTagName("div").GetEnumerator();

            while (e.MoveNext())
            {
                if (TrimHtml((e.Current as IHTMLElement).innerHTML).ToLower().StartsWith(DOMESTIC_TRANSFER_TEXT))
                {
                    IHTMLSelectElement beneficiaryList = doc.getElementById(BENEFICIARY_LIST) as IHTMLSelectElement;
                    if (beneficiaryList == null || doc.getElementsByName(DAY_FIELD).length == 0)
                    {
                        return(false);
                    }
                    else if (request.PaymentInfo.IsDefinedTransfer == false)
                    {
                        return(beneficiaryList.selectedIndex == 0);
                    }
                    else
                    {
                        String text = TrimHtml((beneficiaryList.item(beneficiaryList.selectedIndex, null) as IHTMLOptionElement).text).ToLower();
                        if (text.EndsWith(TRUSTED_POSTFIX))
                        {
                            text = text.Substring(0, text.IndexOf(TRUSTED_POSTFIX));
                        }
                        else if (text.EndsWith(NORMAL_POSTFIX))
                        {
                            text = text.Substring(0, text.IndexOf(NORMAL_POSTFIX));
                        }
                        return(request.PaymentInfo.DefinedTransferName.ToLower().Equals(text));
                    }
                }
            }

            return(false);
        }
コード例 #20
0
 public IEnumerable <TElement> GetElementsByName <TElement>(string name)
     where TElement : HtmlElement
 {
     return(_htmlElementFactory.CreateHtmlElements <TElement>(_document.getElementsByName(name)));
 }
コード例 #21
0
ファイル: _1000Pass_BHO.cs プロジェクト: js0007/thousandpass
        IHTMLElement FindElement(string xPath, HTMLDocument doc)
        {
            IHTMLElement theElement = null;

            try
            {
                string[] tmp = xPath.Split(new string[] { "##" }, StringSplitOptions.None);

                string   elementAttributes = tmp[1];
                string[] attributes        = elementAttributes.Split(new string[] { ";" }, StringSplitOptions.None);
                string   attributeId       = attributes[0].Replace(@"id=", "");
                string   attributeName     = attributes[1].Replace(@"name=", "");
                string   attributeClass    = attributes[2].Replace(@"class=", "");

                string[] xPathParts     = tmp[0].Split('/');
                string   elementTagName = xPathParts[xPathParts.Length - 1];
                if (elementTagName.Contains("["))
                {
                    elementTagName = elementTagName.Split('[')[0];
                }


                // try in first place the id (if it's unique)
                theElement = doc.getElementById(attributeId);
                if (theElement != null && !String.IsNullOrEmpty(attributeId))
                {
                    int c = 0;
                    IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                    foreach (IHTMLElement possibleElement in possibleElements)
                    {
                        if (possibleElement.id == attributeId)
                        {
                            c++;
                        }
                    }

                    if (c > 1)
                    {
                        theElement = null;
                    }
                }


                if (theElement == null && !String.IsNullOrEmpty(attributeName))
                {
                    IHTMLElementCollection possibleElements = doc.getElementsByName(attributeName);
                    if (possibleElements.length == 1)
                    {
                        theElement = (IHTMLElement)possibleElements.item(null, 0);
                    }
                }


                // try next, the exact xpath
                try
                {
                    if (theElement == null)
                    {
                        IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                        foreach (IHTMLElement possibleElement in possibleElements)
                        {
                            string possibleXPath = "";
                            try
                            {
                                possibleXPath = Utils.FindXPath(possibleElement);
                                //Utils.l(possibleXPath);
                            }
                            catch (Exception e) {
                                //Utils.l(e);
                            }

                            if (possibleXPath == xPath)
                            {
                                theElement = possibleElement;
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.l(ex);
                }


                try
                {
                    // next, try the path skipping attributes
                    if (theElement == null)
                    {
                        string cleanXPath = tmp[0];
                        IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                        foreach (IHTMLElement possibleElement in possibleElements)
                        {
                            if (possibleElement.tagName == "INPUT")
                            {
                                IHTMLInputElement tmpInput = (IHTMLInputElement)possibleElement;
                                if (tmpInput.type == "hidden" || tmpInput.type == "text" || tmpInput.type == "password")
                                {
                                    continue;
                                }
                            }

                            string   possibleXPath      = Utils.FindXPath(possibleElement);
                            string[] possibleTmp        = possibleXPath.Split(new string[] { "##" }, StringSplitOptions.None);
                            string   cleanPossibleXPath = possibleTmp[0];

                            if (cleanPossibleXPath == cleanXPath)
                            {
                                theElement = possibleElement;
                                break;
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    Utils.l(ee);
                }
            }
            catch (Exception e)
            {
                Utils.l(e);
            }

            return(theElement);
        }
コード例 #22
0
ファイル: clsAllnew.cs プロジェクト: Lewishui/CITS
        protected void AnalysisWebInfo(object sender, ref object URL)
        {
            SetIE(IeVersion.标准ie8);
            #region  读取网站
            HTMLDocument myDoc = MyWebBrower.Document as HTMLDocument;
            //MessageBox.Show("1");

            if (URL.ToString().IndexOf("https://app.singlewindow.cn/cas/login?service=http") >= 0 && isrun == ProcessStatus.初始化)
            {
                //MessageBox.Show("2");


                IHTMLElement           submit = null;
                IHTMLElement           KEYTX  = null;
                IHTMLInputElement      txtkw  = myDoc.getElementsByName("Login") as IHTMLInputElement;
                IHTMLElementCollection inputs = myDoc.getElementsByTagName("Input");



                foreach (IHTMLElement item in inputs)
                {
                    if (item.outerHTML.IndexOf("password") > 0)
                    {
                        KEYTX = item;
                    }
                    if (item.outerHTML.IndexOf("loginbutton") > 0)
                    {
                        submit = item;
                        break;
                    }
                }

                if (KEYTX != null && KEYTX != null)
                {
                    KEYTX.setAttribute("Value", tsbPassword, 0);
                }
                if (submit != null && submit != null)
                {
                    //MessageBox.Show("32");
                    isrun = ProcessStatus.账号正确;
                    //linshi
                    //isrun = ProcessStatus.第二页面;

                    submit.click();
                }
            }
            if (URL.ToString().IndexOf("https://www.singlewindow.cn/") >= 0 && isrun == ProcessStatus.账号正确)
            {
                IHTMLElementCollection inputs = myDoc.getElementsByTagName("a");
                foreach (IHTMLElement item in inputs)
                {
                    if (item.outerHTML.IndexOf("https://app.singlewindow.cn/userserver/user/index") > 0)
                    {
                        MessageBox.Show("" + item.outerText);
                    }
                    if (item.outerHTML.IndexOf("http://www.chinaport.gov.cn/kafgk/hgzs/18058.htm") > 0)
                    {
                        MessageBox.Show("" + item.outerText);
                        isReadyForSearch = true;
                    }
                }
                isrun = ProcessStatus.检索页面;
            }
            #endregion
        }
コード例 #23
0
        protected override bool IsDefinedTransfersPage(HTMLDocument doc)
        {
            IHTMLElementCollection forms = doc.getElementsByName(DEFINED_TRANSFERS_LIST);

            return(forms.length == 1);
        }
コード例 #24
0
        /// <summary>
        /// Checks if any defined transfer is selected on the transfer page.
        /// </summary>
        /// <param name="doc">HTML document</param>
        /// <returns>true if any defined transfer is selected or false otherwise</returns>
        private bool IsAnyTransferSelected(HTMLDocument doc)
        {
            IHTMLSelectElement select = (doc.getElementsByName(DEFINED_TRANSFER_FIELD) as IHTMLElementCollection).item(0, null) as IHTMLSelectElement;

            return(select.selectedIndex == 0 && "wybierz".Equals(TrimHtml((select.item(0, null) as IHTMLOptionElement).text).ToLower()));
        }
コード例 #25
0
 /// <summary>
 /// Checks if current page is the page where user should provide additional authentication for the transfer e.g. by typing SMS code.
 /// </summary>
 /// <param name="doc">HTML document (current page)</param>
 /// <returns>true if current page is the page where user should provide additional authentication for the transfer,
 /// or false otherwise</returns>
 private bool IsCodeConfirmPage(HTMLDocument doc)
 {
     return(doc.getElementsByName("Code").length == 1);
 }
コード例 #26
0
        public sealed override async Task <Tuple <string, LinkFetchResult> > GetSourceLink(string url)
        {
            var ie = new IE();

            ie.Navigate2(url);

            while (ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            {
            }

            SHDocVw.WebBrowser browser = ((SHDocVw.WebBrowser)ie);
            HTMLDocument       doc     = ((HTMLDocument)browser.Document); //Get Document

            IHTMLElementCollection searchHash = (IHTMLElementCollection)doc.getElementsByName("hash");

            string hash      = string.Empty;
            string timestamp = string.Empty;

            foreach (IHTMLElement element in searchHash)
            {
                if (element == null)
                {
                    break;
                }
                if ((string)element.getAttribute("name") == "hash")
                {
                    hash = element.getAttribute("value");
                }
            }

            IHTMLElementCollection searchTimestamp = (IHTMLElementCollection)doc.getElementsByName("timestamp");

            foreach (IHTMLElement element in searchTimestamp)
            {
                if (element == null)
                {
                    break;
                }
                if ((string)element.getAttribute("name") == "timestamp")
                {
                    timestamp = element.getAttribute("value");
                }
            }

            /* PREPARE POST DATA */

            var stringData = $"hash={HttpUtility.UrlEncode(hash)}&timestamp={HttpUtility.UrlEncode(timestamp)}";
            var byteData   = Encoding.ASCII.GetBytes(stringData);

            /* PREPARE HTTP CLIENT */
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method        = "POST";
            request.UserAgent     = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteData.Length;

            /* SEND POST DATA ASYNC */

            Stream requestStream = await request.GetRequestStreamAsync();

            await requestStream.WriteAsync(byteData, 0, byteData.Length);

            requestStream.Close();

            /* RECIVE RESPONSE ASYNC */
            var response     = ((HttpWebResponse)await request.GetResponseAsync()).GetResponseStream();
            var streamReader = new StreamReader(response, Encoding.Default);

            var responseString = await streamReader.ReadToEndAsync();

            /* PARSE STRING TO DOC  */
            UpdateStatus("Scanning Web page after link");
            var docTemp = (IHTMLDocument2)doc;

            docTemp.write(responseString);

            /* SEARCH DOWNLOAD LINK */
            var contentElement = GetStreamContent(doc);

            var sourceURL     = string.Empty;
            var fetchResponse = LinkFetchResult.SUCCESSFULL;

            if (contentElement != null)
            {
                UpdateStatus("Starting download...");
                sourceURL = contentElement.getAttribute("data-url"); //Get data-url attribute
            }
            else
            {
                fetchResponse = LinkFetchResult.FAILED;
                UpdateStatus("Source link not found");
            }

            ie.Quit();
            return(new Tuple <string, LinkFetchResult>(sourceURL, fetchResponse));
        }
コード例 #27
0
        IHTMLElement FindElement(string xPath, HTMLDocument doc)
        {
            IHTMLElement theElement = null;

            try
            {
                string[] tmp = xPath.Split(new string[] { "##" }, StringSplitOptions.None);

                string elementAttributes = tmp[1];
                string[] attributes = elementAttributes.Split(new string[] { ";" }, StringSplitOptions.None);
                string attributeId = attributes[0].Replace(@"id=", "");
                string attributeName = attributes[1].Replace(@"name=", "");
                string attributeClass = attributes[2].Replace(@"class=", "");

                string[] xPathParts = tmp[0].Split('/');
                string elementTagName = xPathParts[xPathParts.Length - 1];
                if (elementTagName.Contains("["))
                {
                    elementTagName = elementTagName.Split('[')[0];
                }

                // try in first place the id (if it's unique)
                theElement = doc.getElementById(attributeId);
                if (theElement != null && !String.IsNullOrEmpty(attributeId))
                {
                    int c = 0;
                    IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                    foreach (IHTMLElement possibleElement in possibleElements)
                    {
                        if (possibleElement.id == attributeId)
                        {
                            c++;
                        }
                    }

                    if (c > 1)
                    {
                        theElement = null;
                    }
                }

                if (theElement == null && !String.IsNullOrEmpty(attributeName))
                {
                    IHTMLElementCollection possibleElements = doc.getElementsByName(attributeName);
                    if (possibleElements.length == 1)
                    {
                        theElement = (IHTMLElement)possibleElements.item(null, 0);
                    }
                }

                // try next, the exact xpath
                try
                {
                    if (theElement == null)
                    {
                        IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                        foreach (IHTMLElement possibleElement in possibleElements)
                        {
                            string possibleXPath = "";
                            try
                            {
                                possibleXPath = Utils.FindXPath(possibleElement);
                                //Utils.l(possibleXPath);
                            }
                            catch (Exception e) {
                                //Utils.l(e);
                            }

                            if (possibleXPath == xPath)
                            {
                                theElement = possibleElement;
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.l(ex);
                }

                try
                {
                    // next, try the path skipping attributes
                    if (theElement == null)
                    {
                        string cleanXPath = tmp[0];
                        IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName);
                        foreach (IHTMLElement possibleElement in possibleElements)
                        {
                            if (possibleElement.tagName == "INPUT") {
                                IHTMLInputElement tmpInput = (IHTMLInputElement)possibleElement;
                                if (tmpInput.type == "hidden" || tmpInput.type == "text" || tmpInput.type == "password")
                                {
                                    continue;
                                }
                            }

                            string possibleXPath = Utils.FindXPath(possibleElement);
                            string[] possibleTmp = possibleXPath.Split(new string[] { "##" }, StringSplitOptions.None);
                            string cleanPossibleXPath = possibleTmp[0];

                            if (cleanPossibleXPath == cleanXPath)
                            {
                                theElement = possibleElement;
                                break;
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    Utils.l(ee);
                }

            }
            catch (Exception e)
            {
                Utils.l(e);
            }

            return theElement;
        }