Sign in to follow this  
Followers 0
Noobster24

Source is different after submit form..

4 posts in this topic

Hi guys,

this is my script to enter something to my form from AutoIt...

#include <IE.au3>
#include <File.au3>
#include <FTP.au3>

; Create an invisible IE
$oIE = _IECreate(0)
$sq = "norton"
_IENavigate($oIE, "http://localhost/~ OSS ~/search.php")
$o_form = _IEFormGetObjByName ($oIE, "search")
$o_login = _IEFormElementGetObjByName ($o_form, "q")    
_IEFormElementSetValue ($o_login, $sq)
_IEFormSubmit($o_form)
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://localhost/~ OSS ~/search.php")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext

$filec = _FileCreate(@ScriptDir & "\list.txt")
$file = FileOpen(@ScriptDir & "\list.txt", 1)
      
FileWrite($file, $HTMLSource)   

_IEQuit($oIE)

I use a form in HTML with method = post, this is my form:

<form action="search.php" method="post" name="search">

<input name="q" type="text" />

<input type="submit" value="Search" />

<input name="post" type="hidden" />

</form>

When i execute the program to get the source, the source is writed into the file. But the source isn't correct, because, normally after you pressed the submit button, the source will be different from the form.

Example:

This is the source of search.php before i pressed the submit button:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<form action="search.php" method="post" name="search">
<input name="q" type="text" />
<input type="submit" value="Search" />
<input name="post" type="hidden" />
</form>
</body>
</html>

and this is the source of search.php after i enterd 'norton' in the inputbox and pressed the submit button:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
norton-4-norton<br />norton antivirus-5-norton<br /></body>
</html>

But the source that is written into the list.txt is the first source code, how can i get the source of search.php, after the program 'pressed' the submit button?

cheers,

Andreas


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Instead of using winhttprequest have you tried _IEDocReadHTML() or _IEBodyReadHTML() ?

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

#3 ·  Posted (edited)

Instead of using winhttprequest have you tried _IEDocReadHTML() or _IEBodyReadHTML() ?

Dale

Great thanks, that's what i needed, ty so much!! :D:D:cheers:

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Nope, i didn't use it before, how should i use the function?

//Edit: I'm working with v1.0 of IE.au3 and when i try to 'convert' my script to v2.0 of your IE.au3, it only gives errors, so this needs to work with v1.0 :D:D

I'd be interested in any errors you receive trying to use T2.0 -- my goal was to make them compatible. Another source of errors is that T2.0 required a more recent beta than T1.0 does... perhaps try that.

_IEDocReadHTML is new in T2.0. _IEBodyReadHTML was in T1.0. Usage:

$sHTML = _IEBodyReadHTML($oIE)

$sHTML now contains the HTML from the page body.

Dale


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

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