Page 1 sur 3

Contenu d'un web gadget

Publié : mar. 23/mai/2006 19:26
par brossden
Bonjour à tous

Comment faire pour recuperer le contenu d'un webgadget ?
Autrement dit est il possible de mettre le texte contenu dans une page web dans le presse papier (clipboard) et non son adresse !!

Par avance merci ! :lol:

Publié : mar. 23/mai/2006 20:16
par Droopy

Publié : mar. 23/mai/2006 20:18
par brossden
Merci Droppy je vais voir de ce pas !! :P

Publié : mar. 23/mai/2006 20:30
par brossden
Désolé je ne pige pas comment utiliser le code !!! :cry:

Publié : mar. 23/mai/2006 23:25
par Droopy
PB 3.94 ( Code de Gnozal )

Code : Tout sélectionner

; 
; Get HTML Text In WebGadget 
; 
; NOT COMPATIBLE WITH FREAK'S WebGadgetExtras.pb 
; 
Interface IHTMLDocument2_FIXED 
  QueryInterface(a,b) 
  AddRef() 
  Release() 
  GetTypeInfoCount(a) 
  GetTypeInfo(a,b,c) 
  GetIDsOfNames(a,b,c,d,e) 
  Invoke(a,b,c,d,e,f,g,h) 
  get_Script(a) 
  get_all(a) 
  get_body(a) 
  get_activeElement(a) 
  get_images(a) 
  get_applets(a) 
  get_links(a) 
  get_forms(a) 
  get_anchors(a) 
  put_title(a) 
  get_title(a) 
  get_scripts(a) 
  put_designMode(a) 
  get_designMode(a) 
  get_selection(a) 
  get_readyState(a) 
  get_frames(a) 
  get_embeds(a) 
  get_plugins(a) 
  put_alinkColor(a) 
  get_alinkColor(a) 
  put_bgColor(a) 
  get_bgColor(a) 
  put_fgColor(a) 
  get_fgColor(a) 
  put_linkColor(a) 
  get_linkColor(a) 
  put_vlinkColor(a) 
  get_vlinkColor(a) 
  get_referrer(a) 
  get_location(a) 
  get_lastModified(a) 
  put_URL(a) 
  get_URL(a) 
  put_domain(a) 
  get_domain(a) 
  put_cookie(a) 
  get_cookie(a) 
  put_expando(a) 
  get_expando(a) 
  put_charset(a) 
  get_charset(a) 
  put_defaultCharset(a) 
  get_defaultCharset(a) 
  get_mimeType(a) 
  get_fileSize(a) 
  get_fileCreatedDate(a) 
  get_fileModifiedDate(a) 
  get_fileUpdatedDate(a) 
  get_security(a) 
  get_protocol(a) 
  get_nameProp(a) 
  write(a) 
  writeln(a) 
  open(a,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4,e) 
  close() 
  clear() 
  queryCommandSupported(a,b) 
  queryCommandEnabled(a,b) 
  queryCommandState(a,b) 
  queryCommandIndeterm(a,b) 
  queryCommandText(a,b) 
  queryCommandValue(a,b) 
  execCommand(a,b,c,d) 
  execCommandShowHelp(a,b) 
  createElement(a,b) 
  put_onhelp(a1,a2,a3,a4) 
  get_onhelp(a) 
  put_onclick(a1,a2,a3,a4) 
  get_onclick(a) 
  put_ondblclick(a1,a2,a3,a4) 
  get_ondblclick(a) 
  put_onkeyup(a1,a2,a3,a4) 
  get_onkeyup(a) 
  put_onkeydown(a1,a2,a3,a4) 
  get_onkeydown(a) 
  put_onkeypress(a1,a2,a3,a4) 
  get_onkeypress(a) 
  put_onmouseup(a1,a2,a3,a4) 
  get_onmouseup(a) 
  put_onmousedown(a1,a2,a3,a4) 
  get_onmousedown(a) 
  put_onmousemove(a1,a2,a3,a4) 
  get_onmousemove(a) 
  put_onmouseout(a1,a2,a3,a4) 
  get_onmouseout(a) 
  put_onmouseover(a1,a2,a3,a4) 
  get_onmouseover(a) 
  put_onreadystatechange(a1,a2,a3,a4) 
  get_onreadystatechange(a) 
  put_onafterupdate(a1,a2,a3,a4) 
  get_onafterupdate(a) 
  put_onrowexit(a1,a2,a3,a4) 
  get_onrowexit(a) 
  put_onrowenter(a1,a2,a3,a4) 
  get_onrowenter(a) 
  put_ondragstart(a1,a2,a3,a4) 
  get_ondragstart(a) 
  put_onselectstart(a1,a2,a3,a4) 
  get_onselectstart(a) 
  elementFromPoint(a,b,c) 
  get_parentWindow(a) 
  get_styleSheets(a) 
  put_onbeforeupdate(a1,a2,a3,a4) 
  get_onbeforeupdate(a) 
  put_onerrorupdate(a1,a2,a3,a4) 
  get_onerrorupdate(a) 
  toString(a) 
  createStyleSheet(a,b,c) 
EndInterface 

Interface IHTMLElement_FIXED 
  QueryInterface(a,b) 
  AddRef() 
  Release() 
  GetTypeInfoCount(a) 
  GetTypeInfo(a,b,c) 
  GetIDsOfNames(a,b,c,d,e) 
  Invoke(a,b,c,d,e,f,g,h) 
  setAttribute(a,b,c) 
  getAttribute(a,b,c) 
  removeAttribute(a,b,c) 
  put_className(a) 
  get_className(a) 
  put_id(a) 
  get_id(a) 
  get_tagName(a) 
  get_parentElement(a) 
  get_style(a) 
  put_onhelp(a1,a2,a3,a4) 
  get_onhelp(a) 
  put_onclick(a1,a2,a3,a4) 
  get_onclick(a) 
  put_ondblclick(a1,a2,a3,a4) 
  get_ondblclick(a) 
  put_onkeydown(a1,a2,a3,a4) 
  get_onkeydown(a) 
  put_onkeyup(a1,a2,a3,a4) 
  get_onkeyup(a) 
  put_onkeypress(a1,a2,a3,a4) 
  get_onkeypress(a) 
  put_onmouseout(a1,a2,a3,a4) 
  get_onmouseout(a) 
  put_onmouseover(a1,a2,a3,a4) 
  get_onmouseover(a) 
  put_onmousemove(a1,a2,a3,a4) 
  get_onmousemove(a) 
  put_onmousedown(a1,a2,a3,a4) 
  get_onmousedown(a) 
  put_onmouseup(a1,a2,a3,a4) 
  get_onmouseup(a) 
  get_document(a) 
  put_title(a) 
  get_title(a) 
  put_language(a) 
  get_language(a) 
  put_onselectstart(a1,a2,a3,a4) 
  get_onselectstart(a) 
  scrollIntoView(a) 
  contains(a,b) 
  get_sourceIndex(a) 
  get_recordNumber(a) 
  put_lang(a) 
  get_lang(a) 
  get_offsetLeft(a) 
  get_offsetTop(a) 
  get_offsetWidth(a) 
  get_offsetHeight(a) 
  get_offsetParent(a) 
  put_innerHTML(a) 
  get_innerHTML(a) 
  put_innerText(a) 
  get_innerText(a) 
  put_outerHTML(a) 
  get_outerHTML(a) 
  put_outerText(a) 
  get_outerText(a) 
  insertAdjacentHTML(a,b) 
  insertAdjacentText(a,b) 
  get_parentTextEdit(a) 
  get_isTextEdit(a) 
  click() 
  get_filters(a) 
  put_ondragstart(a1,a2,a3,a4) 
  get_ondragstart(a) 
  toString(a) 
  put_onbeforeupdate(a1,a2,a3,a4) 
  get_onbeforeupdate(a) 
  put_onafterupdate(a1,a2,a3,a4) 
  get_onafterupdate(a) 
  put_onerrorupdate(a1,a2,a3,a4) 
  get_onerrorupdate(a) 
  put_onrowexit(a1,a2,a3,a4) 
  get_onrowexit(a) 
  put_onrowenter(a1,a2,a3,a4) 
  get_onrowenter(a) 
  put_ondatasetchanged(a1,a2,a3,a4) 
  get_ondatasetchanged(a) 
  put_ondataavailable(a1,a2,a3,a4) 
  get_ondataavailable(a) 
  put_ondatasetcomplete(a1,a2,a3,a4) 
  get_ondatasetcomplete(a) 
  put_onfilterchange(a1,a2,a3,a4) 
  get_onfilterchange(a) 
  get_children(a) 
  get_all(a) 
EndInterface 
; 
Procedure.l GetBSTRLength(bstr) 
  Length = WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, 0, 0, 0, 0) 
  ProcedureReturn Length 
EndProcedure 
; 
Procedure.l ReadBSTRMem(*Buffer, bstr, Length) 
  Length = WideCharToMultiByte_(#CP_ACP, 0, bstr, -1, *Buffer, Length, 0, 0)    
  ProcedureReturn Length 
EndProcedure 
; 
Procedure WebGadget_GextHTMLText(WebGadget.l) 
  Protected WebObject.IWebBrowser2, HTMLDoc.IHTMLDocument2_FIXED, DocDispatch.IDispatch, HTMLElement.IHTMLElement_FIXED 
  WebObject = GetWindowLong_(GadgetID(WebGadget), #GWL_USERDATA) 
  
  If WebObject\get_document(@DocDispatch) = #S_OK 
    If DocDispatch\QueryInterface(?IID_IHTMLDocument2, @HTMLDoc) = #S_OK 
      If HTMLDoc\get_body(@HTMLElement) = #S_OK 
        If HTMLElement\get_innerHTML(@bstr_code) = #S_OK 
          
          bstr_len = GetBSTRLength(bstr_code) 
          If bstr_len 
            *Buffer = AllocateMemory(bstr_len) 
            If *Buffer 
              If ReadBSTRMem(*Buffer, bstr_code, bstr_len) ; Get HTML code in *Buffer 
                Debug PeekS(*Buffer) ; [warning string size limitation, better use memory functions !] 
              EndIf 
              FreeMemory(*Buffer) 
            EndIf 
          EndIf 
          
          SysFreeString_(bstr_code) 
        EndIf 
      EndIf 
      DocDispatch\Release() 
    EndIf 
  EndIf 
  ProcedureReturn 
  
EndProcedure 

DataSection 
IID_IHTMLDocument2: ; {332C4425-26CB-11D0-B483-00C04FD90119} 
Data.l $332C4425 
Data.w $26CB, $11D0 
Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19        
EndDataSection


OpenWindow(0,0,0,600,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"WebGadget") 
CreateGadgetList(WindowID(0))
WebGadget(0,10,10,580,280,"http://www.purebasic.com")
Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow

Debug PeekS(WebGadget_GextHTMLText(0))
Le source de la page Web apparait dans la fenêtre de débogage.
Je n'arrive pas à afficher le source autrement que dans le débogueur :oops:

Sinon ce code de pille pourrais peut être faire l'affaire ?

Code : Tout sélectionner

;/ Author : Pille
; Proxy like this : "192.168.0.1:8080"

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


;/ Test 
; #Site="http://google.com"
; MessageRequester(#Site,Url2Text(#Site))

Publié : mar. 23/mai/2006 23:42
par Droopy
Ce code de Freak copie le contenu d'un Webgadget dans le presse papier
PB 3.94

Code : Tout sélectionner

; English forum: http://purebasic.myforums.net/viewtopic.php?t=7337 
; Author: Freak 
; Date: 26. August 2003 

; modified for PB3.80 by Freak on 07th September 2003 

Enumeration 1 
  #OLECMDID_OPEN          
  #OLECMDID_NEW        
  #OLECMDID_SAVE          
  #OLECMDID_SAVEAS            
  #OLECMDID_SAVECOPYAS    
  #OLECMDID_PRINT        
  #OLECMDID_PRINTPREVIEW        
  #OLECMDID_PAGESETUP        
  #OLECMDID_SPELL            
  #OLECMDID_PROPERTIES  
  #OLECMDID_CUT          
  #OLECMDID_COPY        
  #OLECMDID_PASTE            
  #OLECMDID_PASTESPECIAL    
  #OLECMDID_UNDO            
  #OLECMDID_REDO          
  #OLECMDID_SELECTALL        
  #OLECMDID_CLEARSELECTION 
  #OLECMDID_ZOOM            
  #OLECMDID_GETZOOMRANGE      
  #OLECMDID_UPDATECOMMANDS  
  #OLECMDID_REFRESH            
  #OLECMDID_STOP              
  #OLECMDID_HIDETOOLBARS      
  #OLECMDID_SETPROGRESSMAX    
  #OLECMDID_SETPROGRESSPOS  
  #OLECMDID_SETPROGRESSTEXT    
  #OLECMDID_SETTITLE          
  #OLECMDID_SETDOWNLOADSTATE  
  #OLECMDID_STOPDOWNLOAD      
EndEnumeration 

Enumeration 0 
  #OLECMDEXECOPT_DODEFAULT      
  #OLECMDEXECOPT_PROMPTUSER        
  #OLECMDEXECOPT_DONTPROMPTUSER    
  #OLECMDEXECOPT_SHOWHELP        
EndEnumeration 

; ----------------------------------------------------- 

; Now the code 

#WebGadget = 1 
#Button = 2 

OpenWindow(0, 0, 0, 800, 600, #PB_Window_ScreenCentered|#PB_Window_SystemMenu, "WebBrowser") 
CreateGadgetList(WindowID()) 

WebGadget(#WebGadget, 10, 40, 780, 550, "www.purebasic.com") 
ButtonGadget(#Button, 10, 10, 60, 20, "Copy") 

; Fred the genius stored the Interface pointer to IWebBrowser2 in the DATA 
; member of the windowstructure of the WebGadget containerwindow, so we can get 
; that easily: 
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA) 

Repeat 
  Event = WaitWindowEvent() 
  If Event = #PB_EventGadget And EventGadgetID() = #Button 
    
    ; Now here's the actual copy thing, not that complicated... 
    WebObject\ExecWB(#OLECMDID_COPY, #OLECMDEXECOPT_DONTPROMPTUSER, 0, 0) 
    
    ; little test: 
    MessageRequester("", GetClipboardText(), 0) 
    
  EndIf 
Until Event = #PB_EventCloseWindow 

Publié : mer. 24/mai/2006 17:01
par brossden
Pour Droopy

Je te remercie Droopy mais je ne sais pas si c'est à cause de la version 4 que j'utilise mais même adapté à PB4 le code ne fonctionne pas !

Publié : mer. 24/mai/2006 19:51
par brossden
Un grand merci Droopy !

Le code de Pille me convient 100% !!

Publié : mer. 24/mai/2006 20:05
par Droopy
C'est celui que j'utilise aussi :wink:

Publié : sam. 14/oct./2006 11:31
par Backup
le code de Pille
marchait hier soir chez moi,je m'en servait pour faire de la recup des numero de loto !!
et ce matin j'ai des petits carreaux
en lieu et place des caracteres ! 8O
et ce, quelques soit l'adresse internet passé ! 8O
impossible de recuperer quelques chose de coherant

il fonctionne chez vous ?

doit-je en conclure que Wanadoo m'empeche d'utiliser cette methode de recuperation ? 8O
j'y comprends plus rien :?

Publié : sam. 14/oct./2006 11:43
par brossden
Quelle adresse utilises tu pour faire cette recup ?

Publié : sam. 14/oct./2006 12:05
par Backup
brossden a écrit :Quelle adresse utilises tu pour faire cette recup ?
La n'est pas la question :D

le problem c'est que ce code ne me renvois plus rien de coherent depuis hier soir !!

hier il marchait , c'est a dire qu'il m'affichait des caracteres comprehensible
(le source de la page passé en parametre)

mais ce matin plus rien, quelque soit l'adresse !!
je n'ai plus que des code non affichable symbolisé par un petit carré !!

chez vous marche t'il ce code ? , affiche t'il des caracteres en clair
representant le source de la page html, donné dans l'adresse ??
8O

Publié : sam. 14/oct./2006 12:11
par Backup
Aie !
Ewido viens de me detecter un Trojan (MYgot)
il est possible que le problemme vienne de la !!
dans un sens ce serai une bonne nouvelle car cela voudrai dire que
si le code de Pill renvoi des données incoherente
c'est que le system est infecté !! :D

Mais j'attends vos reponse pour me confirmer que chez vous le code marche :D

Publié : sam. 14/oct./2006 12:32
par brossden
Je pense effectivement que ton Cheval de Troie t'empêche d'obtenir ce que tu veux mais le lien suivant te sera peut être utile !

http://www.fdjeux.com/generated/dyn/loto/loto.zip

Publié : sam. 14/oct./2006 12:45
par Kwai chang caine
Bonjour DOBRO

Youpi, pour une fois que je peux t'aider un peu, et repondre à une de tes questions, je saute dessus. :onfire:

Je suis aussi chez mamadoo
J'ai éssayé le code de pille et j'ai eu ça (Sans les sauts de ligne) :

Code : Tout sélectionner

<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!--
body,td,a,p,.h{font-family:arial,sans-serif}
.h{font-size:20px}
.q{color:#00c}
--></style>
<script>
<!--
function sf(){document.f.q.focus();}
// -->
</script>
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf() topmargin=3 marginheight=3><center><div align=right nowrap style="padding-bottom:4px" width=100%><font size=-1><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.fr/ig%3Fhl%3Dfr&sig=__UOOLvPRVchoPTs2Ed1BhUD2JZ1Y=">Accueil personnalisé</a>&nbsp;|&nbsp;<a href="https://www.google.com/accounts/Login?continue=http://www.google.fr/&hl=fr">Connexion</a></font></div><img src="/intl/fr_fr/images/logo.gif" width=276 height=110 alt="Google"><br><br>
<form action=/search name=f><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap><font size=-1><b>Web</b>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="/imghp?hl=fr&ie=UTF-8&tab=wi">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://groups.google.fr/grphp?hl=fr&ie=UTF-8&tab=wg">Groupes</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://news.google.fr/nwshp?hl=fr&ie=UTF-8&tab=wn">Actualités</a>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="/intl/fr/options/" class=q >plus&nbsp;&raquo;</a></b></font></td></tr></table><table cellspacing=0 cellpadding=0><tr><td width=25%>&nbsp;</td><td align=center><input type=hidden name=hl value=fr><input type=hidden name=ie value="ISO-8859-1"><input maxlength=2048 size=55 name=q value="" title="Recherche Google"><br><input type=submit value="Recherche Google" name=btnG><input type=submit value="J'ai de la chance" name=btnI></td><td valign=top nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=/advanced_search?hl=fr>Recherche avancée</a><br>&nbsp;&nbsp;<a href=/preferences?hl=fr>Préférences</a><br>&nbsp;&nbsp;<a href=/language_tools?hl=fr>Outils linguistiques</a></font></td></tr><tr><td colspan=3 align=center><font size=-1>Rechercher dans : <input id=all type=radio name=meta value="" checked><label for=all> Web </label><input id=lgr type=radio name=meta value="lr=lang_fr" ><label for=lgr> Pages francophones </label><input id=cty type=radio name=meta value="cr=countryFR" ><label for=cty> Pages : France </label></font></td></tr></table></form><br><br><font size=-1><a href=/ads/>Publicité</a> - <a href=/services/>Solutions d'entreprise</a> - <a href=/intl/fr/about.html>À propos de Google</a> - <a href=http://www.google.com/ncr>Google.com in English</a></font><p><font size=-2>&copy;2006 Google</font></p></center></body></html>
Voila j'espere que ça pourra t'aider à résoudre ton probléme, parce que moi je peux pas faire mieux..., je suis à fond :lol: :lol: