Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub AccederFoto()
- Dim pedido As HttpWebRequest
- Dim respuesta As HttpWebResponse = Nothing
- Dim reader As StreamReader
- Dim direccion As Uri = New Uri("https://www.fotositio.es/Fotos/LoginPage")
- Dim byteData() As Byte
- Dim postStream As Stream = Nothing
- Dim fot1, fot2, key, clave As String
- ''Conectando con el sitio
- pedido = DirectCast(WebRequest.Create(direccion), HttpWebRequest)
- 'Especificando envio POST
- pedido.Method = "POST"
- pedido.ContentType = "multipart/form-data"
- '' Datos que voy a enviar....
- '' Datos de Prueba
- fot1= "12200724"
- fot2= Left(fot1, 2) & "." & Mid(fot1, 3, 3) & "." & Right(fot1, 3)
- key = "3"
- clave = "elpass"
- Dim DatosTotales As New StringBuilder
- DatosTotales.Append("fot1=" & fot1)
- DatosTotales.Append("&fot1=" & fot2)
- DatosTotales.Append("&key=" & key)
- DatosTotales.Append("&clave=" & clave)
- '' Creando Arrays de los datos que se van a enviar
- byteData = UTF8Encoding.UTF8.GetBytes(DatosTotales.ToString())
- '' Enviando el contenido
- pedido.ContentLength = byteData.Length
- Try
- postStream = pedido.GetRequestStream()
- postStream.Write(byteData, 0, byteData.Length)
- Catch ex As Exception
- MsgBox(ex.Message)
- Finally
- If Not postStream Is Nothing Then postStream.Close()
- End Try
- Try
- ' Obteniendo respuesta
- respuesta = DirectCast(pedido.GetResponse(), HttpWebResponse)
- ' Obteniendo respuesta!!
- reader = New StreamReader(respuesta.GetResponseStream())
- ' Sacando resultados
- Response.Write(reader.ReadToEnd())
- Catch ex As Exception
- MsgBox(ex.Message)
- Finally
- If Not Response Is Nothing Then Response.Close()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment