IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Web & réseau Delphi Discussion :

Connexion à un compte d'un site web


Sujet :

Web & réseau Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 8
    Par défaut Connexion à un compte d'un site web
    Bonjour,
    je n'arrive pas à faire l'opération suivante :
    considérons une page web avec :
    -un label marqué login et un edit pour le taper
    -un label marqué password et un edit pour le taper
    -et un bouton marqué authenticate

    je voudrais que mon logiciel "simule" le remplissage des champs login et password puis le clic sur le bouton, le tout SANS UTILISER DE WEB BROWSER, le but étant que ça aille plus vite que de le faire soit même.

    Voila le code source de la page web, merci pour votre aide.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
     
    <html>
    <head>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <link rel="SHORTCUT ICON" href="/favicon.ico">
     
    <title>WebAuth</title>
    <script language="JavaScript"> 
     
    if (window.opener) {
    	window.opener.location.href = document.location.href;
    	self.close();
    }	
     
    if (top.location != document.location) top.location.href = document.location.href;
     
    var is_DOM = (document.getElementById)? true : false;
    var is_NS4 = (document.layers && !is_DOM)? true : false;
     
    var sAgent = navigator.userAgent;
    var bIsIE = (sAgent.indexOf("MSIE") > -1)? true : false;
    var bIsNS = (is_NS4 || (sAgent.indexOf("Netscape") > -1))? true : false;
    var bIsMoz5 = ((sAgent.indexOf("Mozilla/5") > -1) && !bIsIE)? true : false;
     
    if (is_NS4 || bIsMoz5)	{
        document.writeln("<style type=\"text/css\">");
        document.writeln(".operadummy {}");
        document.writeln("</style>");
    }else if (is_DOM) {
        document.writeln("<style type=\"text/css\">");
        document.writeln("body {");
        document.writeln("	font-family: \"Verdana\", \"Arial\", \"Helvetica\", \"sans-serif\";");
        document.writeln("	background-color : #FFFFFF;");
        document.writeln("	background-repeat: no-repeat;");
    	document.writeln("	background-position: center;");
        document.writeln("}");
        document.writeln(".spacer {}");
        document.writeln(".operadummy {}");
        document.writeln("</style>");
    }
     
    function stripSpace(x)
    {
    	return x.replace(/^\W+/,"");
    }
     
    function toggleDisplay(style2)
    {
    	if (style2.display == "block") {
    		style2.display = "none";
    		style2.visibility = "hidden";
    	} else {
    		style2.display = "block";
    		style2.visibility = "";
    	}
    }
     
    function toggleLayer(whichLayer)
    {
    	if (document.getElementById)
    	{
    		var style2 = document.getElementById(whichLayer).style;
    		toggleDisplay(style2);
    	}
    	else if (document.all)
    	{
    		var style2 = document.all[whichLayer].style;
    		toggleDisplay(style2);
    	}
    	else if (document.layers)
    	{
    		var style2 = document.layers[whichLayer].style;
    		toggleDisplay(style2);
    	}
    }
     
    function acceptCheckIt(ok)
    {
    	if (!eval(ok)) {
            top.location.href = "/index.html";
    		return;
    	}
     
    	var fm = document.forms[0];
    	var d = new Date();
    	name = fm.admin_id.value; 
    	pass = fm.admin_pw.value; 
    	if (   (name.length > 0 && name.length < 32) 
    		&& (pass.length > 0 && pass.length < 32)
    	   ) { 
    			fm.submit();
    			return true;
    	 }
    	 return false;
    }
     
    function checkIt() 
    {
     
    		 acceptCheckIt(true);
     
    }  
     
    function cancelIt() 
    {
       return false;
    }		
     
    var margin_top = 0;   
    if (document.layers || bIsMoz5) {
    	margin_top = (window.innerHeight - 330) / 2;
    	if (margin_top < 0) margin_top = 0;
     
    } 
     
    </script> 
    </head>
     
    <body bgcolor="White" link="Black">
     
    <div id="div1" style="display:block">
    <FORM method="POST" name="webauthlogin" ACTION="/web_auth/index.html">   
      	<INPUT type="hidden" name="edit_cookies" VALUE="">
    <script language="javascript"> 
    	if (bIsMoz5 && (margin_top > 0)) {
    		document.writeln("<table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin-top: " + margin_top + "px;'>");
    	} else {
    		document.writeln("<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'>");
    	}
    </script>
    <td align="center" scope="row">
     
    	<table border='0' cellpadding='0' cellspacing='0'>
    	<tr align="center">
    		<td width='100%' align='center'>
     		<table bgcolor='' background='' border='0'>
    		<tr align="center">
    			<th align="right" style="font-size:10pt;" nowrap="1">User Name: </th>
    			<td align="left" style="font-size:10pt;"><INPUT type=text name="admin_id" tabindex="1" SIZE="21" MAXLENGTH="31" VALUE="">
    			</td>
    		</tr>
     
    		<tr align="center">
    			<th align="right" style="font-size:10pt;">Password: </th>
    			<td align="left" style="font-size:10pt;"><INPUT type="password" name="admin_pw" tabindex="2" SIZE="21" MAXLENGTH="31" VALUE=""> 
    			</td>
    		</tr>
    		<tr align="center">
    			<td>&nbsp;</td>
    			<td align="left">
    			<INPUT type="button" value=" Authenticate " onClick="checkIt();" tabindex=\ "4\">
    			</td>
    		</tr>
     
    		</table>
     
    	</td>
    	</tr>
     
    	</table>
     
    </td>
    </tr>
    </table>
    </FORM>
    </div>
     
    <div id="div2" style="display:none">
    <pre>
     
    </pre>
    <bar />
    <center>
    <FORM name="additional">
    	<INPUT type="button" value="Accept" onclick="acceptCheckIt(true);">
    	&nbsp;
    	<INPUT type="button" value="Decline" onclick="acceptCheckIt(false);">
    </FORM>
     
    </center>
    </div>
     
    </body>
    </html>

  2. #2
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    il suffit de faire une requête HTTP vers /web_auth/index.html
    avec les paramètres en POST (ou éventuellement en GET si le serveur l'accepte)
    admin_id=XXX&admin_pw=YYYY
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  3. #3
    Membre émérite
    Avatar de ouiouioui
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Août 2006
    Messages
    993
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2006
    Messages : 993

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 8
    Par défaut
    Merci de vos réponses mais j'utilise turbo delphi 2006 et je n'ai pas les composants indy.
    Est-il possible de faire autrement avec les composants httpreqresp ou autre?

  5. #5
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    n'importe quel composant HTTP fera l'affaire.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 8
    Par défaut
    Désolé, je ne vois toujours pas bien comment faire, je n'arrive pas à faire marcher le http_query project1.exe donc j'ai essayé avec un httpreqresp et j'ai mis le code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    HTTPReqResp1.UserName := Cite_U_Login.Text;
    HTTPReqResp1.Password := Cite_U_Password.Text;
    HTTPReqResp1.URL := 'http://internet.ciup.fr/web_auth/index.html';
    HTTPReqResp1.SendGet;
    mais ça ne marche pas, existe-t-il une solution n'utilisant que les composants de Turbo Delphi 2006 sans utiliser le webbrowser?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Password manager multi-compte pour connexion sur sites web
    Par NeraOne dans le forum Autres Solutions d'entreprise
    Réponses: 0
    Dernier message: 03/07/2013, 20h50
  2. Connexion automatisée à partir d'un site web
    Par philip_b dans le forum Débuter
    Réponses: 5
    Dernier message: 10/03/2011, 17h34
  3. Connexion impossible avec une installation en site web
    Par DoRiane dans le forum Accès aux données
    Réponses: 4
    Dernier message: 06/07/2007, 14h27
  4. Réponses: 1
    Dernier message: 12/06/2007, 09h30
  5. connexion a un site web
    Par nono08 dans le forum Web
    Réponses: 3
    Dernier message: 26/08/2006, 19h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo