Pregunta

Estoy intentando crear un programa en C # en Visual Studio, que adquiriría fuente HTML de una corriente abierta (o seleccionado, o todos) pestaña (s) en Internet Explorer 8 / (preferido) 9. Estoy cansado de copiar por - browser-> Ver código fuente, Alt + a, alt + c, programa -> alt + v Alguien tiene una idea de cómo se puede solucionar?

¿Fue útil?

Solución

Bueno, no hay una solución fácil para esto creo que lo mejor deberías continuar copiar y pegar. De todos modos, esto es lo que he encontrado navegando por la 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();
                            }
                        }
                    }
                }

Ahora que ha accedido a la URL, envía una petición HTTP GET obtendrá la fuente de sitio en texto sin formato.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top