elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Re: Descarga masiva xml del SAT en: 20 Febrero 2015, 08:18 am
Hola

Ya hice la aplicacion en vb.net 2010, solo que no me funciona cuando los equipos tiene instalada la version 9 o 11 de internet explorer

Les comparto mi codigo

Código
  1.            Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
  2.            Dim prueba As String = htmlDocument.GetType.ToString
  3.            Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Images
  4.            Dim ImagesFound As Integer
  5.  
  6.            For Each htmlElement As HtmlElement In htmlElementCollection
  7.                Dim imgUrl As String = htmlElement.GetAttribute("id")
  8.                If imgUrl = "BtnDescarga" Then
  9.                    imgUrl = Replace(htmlElement.OuterHtml, Chr(34), "")
  10.                    ImagesFound = InStr(imgUrl, "','Recuperacion')")
  11.                    imgUrl = imgUrl.Substring(103, ImagesFound - 104)
  12.                    imgUrl = "https://portalcfdi.facturaelectronica.sat.gob.mx/" & imgUrl
  13.                    ListBox1.Items.Add(imgUrl)
  14.                End If
  15.            Next
  16.  
  17.            Dim URI, archivo As String
  18.            Dim wc As New WebClient
  19.  
  20.            wc.Headers.Add(HttpRequestHeader.Cookie, GetGlobalCookies(WebBrowser1.Document.Url.ToString))
  21.  
  22.            For i = 0 To ListBox1.Items.Count - 1
  23.                URI = ListBox1.Items.Item(i).ToString.Trim
  24.                wc.DownloadFile(URI, ruta a guardar)
  25. next
  26.  
  27.   <DllImport("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True, PreserveSig:=True)> _
  28.    Private Shared Function InternetGetCookieEx(ByVal pchURL As String, ByVal pchCookieName _
  29.                                                As String, ByVal pchCookieData As StringBuilder, _
  30.                                                ByRef pcchCookieData As UInteger, ByVal dwFlags As Integer, _
  31.                                                ByVal lpReserved As IntPtr) As Boolean
  32.    End Function
  33.    Const INTERNET_COOKIE_HTTPONLY As Integer = &H2000
  34.  
  35.    Public Shared Function GetGlobalCookies(ByVal uri As String) As String
  36.        Dim datasize As UInteger = CInt(strCache)
  37.        'Dim datasize As UInteger = 8192
  38.        Dim cookieData As New StringBuilder(CInt(datasize))
  39.        If InternetGetCookieEx(uri, Nothing, cookieData, datasize, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero) AndAlso cookieData.Length > 0 Then
  40.            'Return cookieData.ToString().Replace(";"c, ","c)
  41.            Return cookieData.ToString()
  42.        Else
  43.            Return Nothing
  44.        End If
  45.    End Function

alguna ayuda
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines