Question

Je suis en train de créer un programme en C # dans Visual Studio qui acquerrait source HTML d'un courant ouvert (ou sélectionné, ou tous) onglet (s) dans Internet Explorer 8 / (preféré) 9. Je suis fatigué de copier par - browser-> Afficher la source, alt + a, alt + c, programme -> alt + v Quelqu'un at-il une idée de comment le résoudre?

Était-ce utile?

La solution

Eh bien, il n'y a pas de solution facile pour cela, je pense que peut-être vous devriez continuer à copier et coller. , C'est en tout cas ce que je trouve surfer sur le web: ( http: //www.experts -exchange.com/Microsoft/Development/Q_23767759.html )

{   // used spy++ to get the names of these guys
            // get the handle to the IE toolbar
            childHandle = FindWindowEx(IEwindowHandle, IntPtr.Zero, "WorkerW", IntPtr.Zero);
            if (childHandle != IntPtr.Zero)
            {
                //get the handle to the address bar on IE
                childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ReBarWindow32", IntPtr.Zero);
                if (childHandle != IntPtr.Zero)
                {
                    // get a handle to comboBoxEx32
                    childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBoxEx32", IntPtr.Zero);
                    if (childHandle != IntPtr.Zero)
                    {
                        // get a handle to combo box
                        childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBox", IntPtr.Zero);
                        if (childHandle != IntPtr.Zero)
                        {
                            //get handle to edit
                            childHandle = FindWindowEx(childHandle, IntPtr.Zero, "Edit", IntPtr.Zero);
                            if (childHandle != IntPtr.Zero)
                            {
                                // now to get the URL we need to get the Text - but first get the length of the URL
                                int length = SendMessage(childHandle, WM_GETTEXTLENGTH, 0, 0);
                                length += 1;    // because the length returned above included 0
                                StringBuilder text = new StringBuilder(length); // need stringbuilder - not string
                                int hr = SendMessage(childHandle, WM_GETTEXT, length, text); // get the URL
                                strURL = text.ToString();
                            }
                        }
                    }
                }

Maintenant que vous avez accédé à l'URL, envoyer un requête HTTP GET, vous obtiendrez la source du site en texte brut.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top