Hola @shout, pues casi, pero no, resulta ser que son las cookies, cosa en la que no había caído y gracias a Kub0x pues me he dado cuenta..
Me dio algunos pasos a seguir, pero tiré por libre he hice este code, que por ahora parece que funciona a la perfección:
Parte de esta información la he sacado de un snippet que me ha servido bastante para hacer lo que yo quería:
Un saludo.
Me dio algunos pasos a seguir, pero tiré por libre he hice este code, que por ahora parece que funciona a la perfección:
Código (vbnet) [Seleccionar]
ReadOnly motor As String = "http://mrtzcmp3.net/"
Dim sourceString As String
Dim matches As MatchCollection
ReadOnly regexSearch As String = "D\?.+? _"
Dim firstMatch As String
Dim pageHtml As String
Dim url As String
Dim Cookies As New CookieContainer
Dim cookieString As String
Dim request As System.Net.HttpWebRequest
Dim response As System.Net.HttpWebResponse
Dim cookieName As String
Dim sr As System.IO.StreamReader
Private Sub Buscar()
'Cookie Name
cookieName = "haras"
'Get first source
request = CType(HttpWebRequest.Create(motor & TextBox1.Text & "_1s.html"), HttpWebRequest)
request.CookieContainer = Cookies 'Request Cookies
response = CType(request.GetResponse(), HttpWebResponse)
'DO multiple things with the cookies
For Each cookieValue As Cookie In response.Cookies
If cookieValue.ToString.Substring(0, cookieValue.ToString.IndexOf("=")) = cookieName Then
cookieString = cookieValue.ToString.Replace(cookieName & "=", "") 'Get haras cookie value
End If
Cookies.Add(cookieValue) 'Add cookies to the container for use it again
Next
'Read Source String
sr = New System.IO.StreamReader(response.GetResponseStream())
sourceString = sr.ReadToEnd()
'Check the result
matches = Regex.Matches(sourceString, regexSearch)
'If results = 0 stop sub
If matches.Count = 0 Then
MsgBox("Se encontraron 0 resultados de esta canción.", MsgBoxStyle.Information, "Información")
Exit Sub
End If
'Get first song link
firstMatch = matches.Item(0).Value
'Enter with Fake Cookie
request = CType(HttpWebRequest.Create(motor & firstMatch & cookieString), HttpWebRequest)
request.CookieContainer = Cookies
response = CType(request.GetResponse(), HttpWebResponse)
'Read source String
sr = New System.IO.StreamReader(response.GetResponseStream())
sourceString = sr.ReadToEnd()
'Append text to a new text file (this will be the future step, for get song download link)
If Not File.Exists(".\prueba.html") Then
File.AppendAllText(".\prueba.html", sourceString)
Else
File.Delete(".\prueba.html")
File.AppendAllText(".\prueba.html", sourceString)
End If
'For advise that the function has finished
MsgBox("Done!")
End Sub
Parte de esta información la he sacado de un snippet que me ha servido bastante para hacer lo que yo quería:
Código (vbnet) [Seleccionar]
Private Sub Login_in_FB()
Dim cookieJar As New Net.CookieContainer()
Dim request As Net.HttpWebRequest
Dim response As Net.HttpWebResponse
Dim strURL As String = ""
Try
'Get Cookies
strURL = "https://login.facebook.com/login.php"
request = CType(HttpWebRequest.Create(strURL), HttpWebRequest)
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
request.Method = "GET"
request.CookieContainer = cookieJar
response = CType(request.GetResponse(), HttpWebResponse)
For Each tempCookie As Net.Cookie In response.Cookies
cookieJar.Add(tempCookie)
Next
'Send the post data now
request = CType(HttpWebRequest.Create(strURL), HttpWebRequest)
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
request.Method = "POST"
request.AllowAutoRedirect = True
request.CookieContainer = cookieJar
Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
writer.Write("email=username&pass=password")
writer.Close()
response = CType(request.GetResponse(), HttpWebResponse)
'Get the data from the page
Dim stream As StreamReader = New StreamReader(response.GetResponseStream())
Dim data As String = stream.ReadToEnd()
response.Close()
If data.Contains("<title>Facebook") = True Then
'LOGGED IN SUCCESSFULLY
MessageBox.Show("logged in sucessfully")
Else
MessageBox.Show("Not logged in")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Un saludo.