et tu vois le resultat s'afficher .. (n'oublie pas d'autoriser ton Firewall )
Code : Tout sélectionner
Global site.s = "http://www.smoothjazz.com"
;-declaration
Declare ouvre_fenetre()
Declare.s SearchString(String.s,StartString.s,EndString.s)
Declare.s Url2Text2(Url.s, OpenType.b,ProxyAndPort.s)
Declare.s Url2Text(Url.s)
Declare.s filtre(Var.s)
;-initialisation
Enumeration ; fennetre
#window
EndEnumeration
Enumeration ; gadgets
#editeur
#timer
#editor
EndEnumeration
Enumeration ;Fichier
#file
EndEnumeration
ouvre_fenetre()
;-boucle
Repeat
select WindowEvent()
Case #PB_Event_Timer
if EventTimer() = #timer
interpret.s= SearchString(Url2Text(Site.s),"<span class="+chr(34)+"nowplaying_artist"+chr(34)+">","<")
titre.s= SearchString(Url2Text(Site.s),chr(34)+"nowplaying_song"+chr(34)+">","<")
interpret.s=filtre(interpret.s)
titre.s=filtre(titre.s)
; Affichage Editeur
ClearGadgetItems(#editor)
AddGadgetItem(#editor, 0,"Titre :"+titre.s)
AddGadgetItem(#editor, 0, "Artist: "+interpret.s)
if interpret.s<>"" and titre.s<>""
if OpenFile(#file,"info.txt")
TruncateFile(#File)
WriteString(#file,interpret.s+"-")
WriteString(#file,titre.s)
CloseFile(#file)
Endif
Endif
Endif
Case #PB_Event_CloseWindow
End
Endselect
forever
; ********** Zone des Procedures **********************************
;- zone procedure
Procedure ouvre_fenetre()
OpenWindow(#window,10,10,320,100,"resultat",#PB_Window_SystemMenu )
EditorGadget(#editor,10,10,300,80)
AddWindowTimer(#window, #timer, 10000) ; toute les 10 secondes
EndProcedure
Procedure.s SearchString(String.s,StartString.s,EndString.s)
Global SearchStringIndex,SearchString.s
SearchStringIndex=1
SearchString=String
Start=FindString(SearchString,StartString,SearchStringIndex)
If Start
Start=Start+Len(StartString)
EndIndex=FindString(SearchString,EndString,Start)
If EndIndex
SearchStringIndex=EndIndex+Len(EndString)
ProcedureReturn Mid(SearchString,Start,EndIndex-Start)
Else
EndIndex=Len(SearchString)+1
SearchStringIndex=EndIndex+Len(EndString)
ProcedureReturn Mid(SearchString,Start,EndIndex-Start)
EndIf
Else
Start=1
EndIndex=FindString(SearchString,EndString,Start)
If EndIndex
SearchStringIndex=EndIndex+Len(EndString)
ProcedureReturn Mid(SearchString,Start,EndIndex-Start)
Else
EndIndex=Len(SearchString)+1
SearchStringIndex=EndIndex+Len(EndString)
ProcedureReturn Mid(SearchString,Start,EndIndex-Start)
EndIf
EndIf
EndProcedure
ProcedureDLL.s Url2Text2(Url.s, OpenType.b,ProxyAndPort.s)
; 1 INTERNET_OPEN_TYPE_DIRECT Resolves all host names locally.
; 0 INTERNET_OPEN_TYPE_PRECONFIG Retrieves the proxy Or direct configuration from the registry.
; 4 INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY Retrieves the proxy Or direct configuration from the registry And prevents the use of a startup Microsoft JScript Or Internet Setup (INS) file.
; 3 INTERNET_OPEN_TYPE_PROXY Passes requests To the proxy unless a proxy bypass list is supplied And the name To be resolved bypasses the proxy. In this Case, the function uses INTERNET_OPEN_TYPE_DIRECT.
isLoop.b=1
INET_RELOAD.l = $80000000
hInet.l=0
hURL.l=0
Bytes.l=0
Buffer.s=Space(2048)
res.s=""
hInet = InternetOpen_("", OpenType, ProxyAndPort, "", 0)
hURL = InternetOpenUrl_(hInet, Url, #Null, 0, INET_RELOAD, 0)
Repeat
InternetReadFile_(hURL,@Buffer, Len(Buffer), @Bytes)
If Bytes = 0
isLoop=0
Else
res = res + Left(Buffer, Bytes)
EndIf
Until isLoop=0
InternetCloseHandle_(hURL)
InternetCloseHandle_(hInet)
ProcedureReturn res
EndProcedure
ProcedureDLL.s Url2Text(Url.s)
ProcedureReturn Url2Text2(Url,1,"")
EndProcedure
Procedure.s filtre(Var.s)
for i=32 to 255
if i<100
Var.s = ReplaceString(Var.s,"&#"+"0"+str(i),chr(i) )
Else
Var.s = ReplaceString(Var.s,"&#"+str(i),chr(i) )
Endif
Next i
; By Dobro
; autre exemple de filtre qui a l'avantage que nous voyons directement les caracteres que nous désirons garder , il suffit de les ajouter dans la chaine Ref.s
ref.s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&()/éèê.:[]-' " ; << derniere caractere est un espace
For i=1 to len(var.s)
ex.s=mid(var.s,i,1)
If findstring(ref.s,ex.s)>0
sort.s=sort.s+ex.s
Endif
Next i
ProcedureReturn Sort.s
Endprocedure
; EPB