Sign in to follow this  
Followers 0
rudi

directly retrieve answer of a ASP web page from autoit?

6 posts in this topic

Hi.

The IE functions of Autoit definitely are not what I know much about, so pls. be patient :) , I honestly have no clue how to do a http POST (?) and how to catch and analyse the resulting page returned by the web server using Autoit.

Surfcontrol is a product for content filtering at firewalls / proxies. URLs are categorized, categories can be allowed or denied for certain users, groups, ... .

To make it easier to find out, why a certain site is blocked, surfcontrol is providing this page:

http://mtas2.surfcontrol.com/mtas/MTASNovellv6.1.asp

When entering a certain URL, the returning result is either "... is not in our list", or " ...is in our list and categorized as <category>".

I'd like to write a small applet, that directly just returns this result:

start, run,

surfcontrol[.exe] <site-to-be-checked>,

OK,

msgbox popping up telling the result, no IE window opening at all.

Where to read up / check out how to solve this propably pretty basic task?

Thanks for any suggestions to point me in the right direction.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



Can't you just open IE in the background and catch the result and then close it.

I assume a standard page is shown when the URL is blocked, so if URL is blocked show x else y.

Check IE Management in the helpfile

Share this post


Link to post
Share on other sites

You may be able to use InetGet if they are static pages not needing authentication.

If not, see _IECreate with the invisible flag, _IEBodyReadText and _IEQuit

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

Hi.

You may be able to use InetGet if they are static pages not needing authentication.

This page looks static. It's a form with one edit and one button. What I would need is to know how to "directly" send the POST (?) that IE is doing after I fill the form and press the button.

If not, see _IECreate with the invisible flag, _IEBodyReadText and _IEQuit

I played with _IE*, but failed deperately :)

Thanks for your reply, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here's a start...

#include <IE.au3>
$oIE = _IECreate ("http://mtas2.surfcontrol.com/mtas/MTASV4.asp",0,0)
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oQuery = _IEFormElementGetObjByName ($oForm, "url")
_IEFormElementSetValue ($oQuery, "http://www.bangbros.com")
_IEFormSubmit ($oForm)
$body = _IEBodyReadHTML($oIE)
ConsoleWrite(_IEQuit($oIE) & @crlf)
MsgBox(0,"",$body)
Edited by KaFu

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi.

Thanks a lot for you help!

May be someone else also want's to use this currently working script: (until the next redesign of the answer page ...)

#include <IE.au3>

If $cmdline[0] <> 1 Then Info()
Dim $CategoryLine = ""
$h = 200
$w = 500
$title="Surfcontrol Checker"

$myGUI = GUICreate($title, $w, $h)
$LabelTXT = "Please wait, checking SurfControl v6.1 for BorderManager DB for " & @CRLF & @CRLF & '"'& $cmdline[1]& '"' & @CRLF & @CRLF & "Please be patient ..."
$label = GUICtrlCreateLabel($LabelTXT, 20, 20, $w - 40, $h - 40)
GUISetState(@SW_SHOW)

$oIE = _IECreate("http://mtas2.surfcontrol.com/mtas/MTASV4.asp", 0, 0)
$oForm = _IEFormGetObjByName($oIE, "form1")
$oQuery = _IEFormElementGetObjByName($oForm, "url")
_IEFormElementSetValue($oQuery, $cmdline[1])
_IEFormSubmit($oForm)
$body = _IEBodyReadHTML($oIE)
$BodyArr = StringSplit($body, @CRLF)
For $i = 1 To $BodyArr[0]
    If StringInStr($BodyArr[$i], "is in our list and categorized as") Then
        $CategoryLine = $BodyArr[$i]
        ExitLoop
    EndIf
Next
GUIDelete($myGUI)

If $CategoryLine == "" Then
    MsgBox(0, $title, $cmdline[1] & " is not in our list.")
Else
    $result = StringRegExpReplace($CategoryLine, "(<(.|\n)*?>)", "")
    $result = StringRegExpReplace($result, "(.*?)(?i)(?: if you would like.*$)", "$1")
    $result = StringReplace($result,"&amp;","&")
    MsgBox(0, $title, $result & ".")
EndIf

Func Info()
    MsgBox(0, "SurfControl Checker: Lookup Applet for Version 6.1 for Novell Bordermanager", _
            "To lookup, what's the category for the site www.google.de use this syntax:" & @LF & @LF & _
            StringRegExpReplace(@ScriptName, "(\..*)", "") & " www.google.de" & @LF, 20)
    Exit
EndFunc   ;==>Info

Regards, Rudi.

[edit: grammar]

[edit2: "&amp;" -> "&"]

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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