Bien, como soy guitarrista pues me paso el día buscando tablaturas de canciones que me gustan para poder tocarlas en mis ratos de aburrimiento asi que se me ocurrión hacer un programita que me permita buscar las tablaturas en las páginas y descargar o bien todas las tablaturas de ese artista o solo todas las pertenecientes a la canción especificada.
Por ahora tengo lo siguiente, sé que faltan muchas cosas, que creo que si las sabré hacer, el problema es que obtengo la lista de canciones (perfectamente), accedo a la lista de enlaces de cada canción (genial) pero, el problema lo tengo a la hora de obtener el link de descargar del archivo guitar pro (extensiones: *.gp3, *.gp4, *.gp5 y *.gpx) ya que en una de las webs a las que recurre, el enlace de descarga se genera por un botón que llama a una función javascript.
Dejo un ejemplo;
Uno de los links que obtiene puede ser "http://www.911tabs.com/link/?2228691" probado y funcional, ahora, que hay en ese link?, es un iframe que engloba a la página real, pues se obtiene el link de ese iframe y se analiza la página, nos sale este link: http://tabs.ultimate-guitar.com/g/gamma ... ar_pro.htm
De aqui, podemos ver el problema que tengo, el código por el que se genera el enlace está dentro de la página y la estructura no es complicada, es solo que no entiendo como puedo obtener el link, que como resultado es este
http://www.ultimate-guitar.com/tab_down ... e494687da7
Saludos!
Gracias
Codigo:
Código: Seleccionar todo
#include <inet.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <String.au3>
#include <Misc.au3>
#include <GuiMenu.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("GuitarProTab Downloader", 539, 424, 192, 124)
$Label1 = GUICtrlCreateLabel("Artista", 32, 24, 33, 17)
$Input1 = GUICtrlCreateInput("", 80, 22, 305, 21)
$Group1 = GUICtrlCreateGroup("Tablaturas", 8, 48, 521, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Buscar", 416, 18, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Descargar", 8, 384, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Descargar todas", 96, 384, 99, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$hListView = GUICtrlCreateListView("Titulo|Enlace", 14,70, 500, 300)
_GUICtrlListView_SetColumnWidth($hListView, 0, 220)
_GUICtrlListView_SetColumnWidth($hListView, 1, 260)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
rellenar(StringLeft(GUICtrlRead($Input1),1),Stringreplace(GUICtrlRead($Input1)," ","_"))
Case $Button2
$total = _GUICtrlListView_GetItemCount($hListView)
For $a = 0 To $total
If _GUICtrlListView_GetItemSelected($hListView, $a) = True Then
$artista = _GUICtrlListView_GetItemText($hListView, $a)
$url = _GUICtrlListView_GetItemText($hListView, $a, 1)
download($url,$name,GUICtrlRead($Input1))
EndIf
Next
EndSwitch
WEnd
Func rellenar($inicial,$artista)
$dir = "http://www.911tabs.com/tabs/"&$inicial&"/"&$artista&"/guitar_pro_tabs/"
$code = _INetGetSource($dir)
$cuerpo = StringRegExp($code, '(?s)<td><a href="(.*?)">(.*?)</a></td>(?s)', 3)
For $a = 0 To UBound($cuerpo) Step 2
If $a == UBound($cuerpo) - 2 Then ExitLoop
GUICtrlCreateListViewItem(Decod($cuerpo[$a + 1]) & "|http://www.911tabs.com/" & $cuerpo[$a], $hListView)
Next
EndFunc ;==>rellenar
Func Decod($text)
$text = StringReplace($text, "“", Chr(82220))
$text = StringReplace($text, "™", Chr(8482))
$text = StringReplace($text, "”", Chr(8221))
$text = StringReplace($text, "‰", Chr(8240))
$text = StringReplace($text, "Œ", Chr(338))
$text = StringReplace($text, "ƒ", Chr(402))
$text = StringReplace($text, "‡", Chr(82225))
$text = StringReplace($text, "†", Chr(82224))
$text = StringReplace($text, "&", Chr(38))
$text = StringReplace($text, """, Chr(34))
$text = StringReplace($text, "Á", Chr(193))
$text = StringReplace($text, "À", Chr(192))
$text = StringReplace($text, "É", Chr(201))
$text = StringReplace($text, "È", Chr(200))
$text = StringReplace($text, "Í", Chr(205))
$text = StringReplace($text, "Ì", Chr(204))
$text = StringReplace($text, "Ó", Chr(211))
$text = StringReplace($text, "Ò", Chr(210))
$text = StringReplace($text, "Ú", Chr(218))
$text = StringReplace($text, "Ù", Chr(217))
$text = StringReplace($text, "á", Chr(225))
$text = StringReplace($text, "à", Chr(224))
$text = StringReplace($text, "é", Chr(233))
$text = StringReplace($text, "è", Chr(232))
$text = StringReplace($text, "í", Chr(237))
$text = StringReplace($text, "ì", Chr(236))
$text = StringReplace($text, "ó", Chr(243))
$text = StringReplace($text, "ò", Chr(242))
$text = StringReplace($text, "ú", Chr(250))
$text = StringReplace($text, "ù", Chr(249))
$text = StringReplace($text, "Ä", Chr(196))
$text = StringReplace($text, "Â", Chr(194))
$text = StringReplace($text, "Ë", Chr(203))
$text = StringReplace($text, "Ê", Chr(202))
$text = StringReplace($text, "Ï", Chr(207))
$text = StringReplace($text, "Î", Chr(206))
$text = StringReplace($text, "Ö", Chr(214))
$text = StringReplace($text, "Ô", Chr(212))
$text = StringReplace($text, "Ü", Chr(220))
$text = StringReplace($text, "Û", Chr(219))
$text = StringReplace($text, "ä", Chr(228))
$text = StringReplace($text, "â", Chr(226))
$text = StringReplace($text, "ë", Chr(235))
$text = StringReplace($text, "ê", Chr(234))
$text = StringReplace($text, "ï", Chr(239))
$text = StringReplace($text, "î", Chr(238))
$text = StringReplace($text, "ö", Chr(246))
$text = StringReplace($text, "ô", Chr(244))
$text = StringReplace($text, "ü", Chr(252))
$text = StringReplace($text, "û", Chr(251))
$text = StringReplace($text, "Ã", Chr(195))
$text = StringReplace($text, "å", Chr(229))
$text = StringReplace($text, "Ñ", Chr(209))
$text = StringReplace($text, "Å", Chr(197))
$text = StringReplace($text, "Õ", Chr(213))
$text = StringReplace($text, "Ç", Chr(199))
$text = StringReplace($text, "ã", Chr(227))
$text = StringReplace($text, "ç", Chr(231))
$text = StringReplace($text, "ñ", Chr(241))
$text = StringReplace($text, "Ý", Chr(221))
$text = StringReplace($text, "õ", Chr(245))
$text = StringReplace($text, "ý", Chr(253))
$text = StringReplace($text, "Ø", Chr(216))
$text = StringReplace($text, "ÿ", Chr(255))
$text = StringReplace($text, "ø", Chr(248))
$text = StringReplace($text, "Þ", Chr(222))
$text = StringReplace($text, "Ð", Chr(208))
$text = StringReplace($text, "þ", Chr(254))
$text = StringReplace($text, "ð", Chr(240))
$text = StringReplace($text, "&AELIG;", Chr(198))
$text = StringReplace($text, "ß", Chr(223))
$text = StringReplace($text, "æ", Chr(230))
$text = StringReplace($text, "¼", Chr(188))
$text = StringReplace($text, " ", Chr(160))
$text = StringReplace($text, "½", Chr(189))
$text = StringReplace($text, "¡", Chr(161))
$text = StringReplace($text, "¾", Chr(190))
$text = StringReplace($text, "£", Chr(163))
$text = StringReplace($text, "©", Chr(169))
$text = StringReplace($text, "¥", Chr(165))
$text = StringReplace($text, "®", Chr(174))
$text = StringReplace($text, "§", Chr(167))
$text = StringReplace($text, "ª", Chr(170))
$text = StringReplace($text, "¤", Chr(164))
$text = StringReplace($text, "²", Chr(178))
$text = StringReplace($text, "¦", Chr(166))
$text = StringReplace($text, "³", Chr(179))
$text = StringReplace($text, "«", Chr(171))
$text = StringReplace($text, "¹", Chr(185))
$text = StringReplace($text, "¬", Chr(172))
$text = StringReplace($text, "¯", Chr(175))
$text = StringReplace($text, "", Chr(173))
$text = StringReplace($text, "µ", Chr(181))
$text = StringReplace($text, "º", Chr(186))
$text = StringReplace($text, "¶", Chr(182))
$text = StringReplace($text, "´", Chr(180))
$text = StringReplace($text, "·", Chr(183))
$text = StringReplace($text, "¨", Chr(168))
$text = StringReplace($text, "°", Chr(176))
$text = StringReplace($text, "±", Chr(177))
$text = StringReplace($text, "¸", Chr(184))
$text = StringReplace($text, "»", Chr(187))
$text = StringReplace($text, "¿", Chr(191))
$text = StringReplace($text, "×", Chr(215))
$text = StringReplace($text, "¢", Chr(162))
$text = StringReplace($text, "÷", Chr(247))
$text = StringReplace($text, "€", Chr(8364))
$text = StringReplace($text, "–", Chr(8211))
Return $text
EndFunc ;==>Decod
func download($link,$nombrearchivo,$artista)
$code = _INetGetSource($link)
$cuerpo = StringRegExp($code, '(?s)<td><a href="(.*?)" rel="nofollow">.*?</a></td>(?s)', 3)
For $a = 0 To UBound($cuerpo)-1
$link = "www.911tabs.com" & $cuerpo[$a]
;$enlacearchivo =
;DirCreate(@DesktopDir&"\"&$artista)
Next
endfunc