Sign in to follow this  
Followers 0
KillingEye

get a formname from html source code

5 posts in this topic

Hi,

how can my autoitscript read a name of a form object?

Part of the html code:

<form method="post" name="snd" action="dorf1.php">
<input type="hidden" name="w" value="">
<input type="hidden" name="login" value="1230109235">

<p><table class="p1" style="width:100%"cellspacing="1" cellpadding="0"><tr><td>

<table width="100%" cellspacing="1" cellpadding="0">
<tr><td><label>Name:</label>
<input class="fm fm110" type="text" name="e8790fb" value="" maxlength="15"> <span class="e f7"></span>
</td></tr>
<tr><td><label>Passwort:</label>
<input class="fm fm110" type="password" name="e88b613" value="" maxlength="20"> <span class="e f7"></span>
</td></tr>
</table></td></tr></table></p>

I need the value of the name :

type="text" name="e8790fb"

and the value of this

type="password" name="e88b613"

The "e8790fb" and the "e88b613" is needed.

so how can i do this?

Ty for any Help ^^

Share this post


Link to post
Share on other sites



Try this:

$sFile = @ScriptDir & "\test.htm"
$sRead = FileRead($sFile)
$sResult = ""

$aResult = StringRegExp($sRead, '(?i)type="text" name="(.*?)"|type="password" name="(.*?)"', 3)

$sResult &= $aResult[0] & @CRLF
$sResult &= $aResult[2] & @CRLF

MsgBox(0, "Result", $sResult)

Share this post


Link to post
Share on other sites

I will try it!

ty...

but a want that the script read the source code of a website... and not of a html file on my pc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Take a look at the _IE funcions. This will get you started:

#include <IE.au3>
$oIE = _IECreate(your-url) ; or use _IEAttach
$oForms = _IEFormGetCollection($oIE, 0) ; not the first form? use 1, 2, 3 till you find it
$oUName = _IEFormElementGetCollection($oForm, 2)
$oPasswort = _IEFormElementGetCollection($oForm, 3)

$sUName = $oUName.name
$sPasswort = $oPasswort.name

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Nice job :o

Ty!!!

It Works :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0