Jump to content

Help understanding snippet of code within my script


Recommended Posts

Hi all,

I'm fairly new to AutoIT and haven't done any type of programming for a while, and I have a questions about the following code. I wrote the following script to automatically download the superdat files from McAfee's website, however the url for the file changes daily, so the script scans all the links, and downloads the link containing the string "sdat"

#include <IE.au3>
$oIE = _IECreate ("http://www.mcafee.com/apps/downloads/security_updates/superdat.asp?region=us&segment=enterprise",0,0)
$sMyString = "sdat"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        inetget ("http://download.nai.com/products/licensed/superdat/english/intel/" & $sLinkText, "C:\Documents and Settings\amohr\Desktop\sdat.exe")
        ExitLoop
    EndIf
next
_IEQuit ($oIE)

I put this together with help from the forums and the help files within scite, and my question is:

I have no idea where "innerText" comes into play. This script works like a charm, and I understand most of the coding pretty well, but cannot get my head around what "innerText" is, what it is a property from, or what it is being pulled from.

Any help would be great!

Thanks.

Link to comment
Share on other sites

Off the cuff (it would pay to look this up) but innerText is a standard HTML deal. Simply it says look inside the property/tag.

I looked it up - see http://msdn.microsoft.com/en-us/library/ms533899(VS.85).aspx.

"Sets or retrieves the text between the start and end tags of the object." Its not M$ specific.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Off the cuff (it would pay to look this up) but innerText is a standard HTML deal. Simply it says look inside the property/tag.

I looked it up - see http://msdn.microsoft.com/en-us/library/ms533899(VS.85).aspx.

"Sets or retrieves the text between the start and end tags of the object." Its not M$ specific.

Great! thank you. I usually google search everything, but didn't on this cuz I was figuring it was some user defined function within AutoIT or some variable i missed somewhere.

Link to comment
Share on other sites

  • 9 months later...

This is great! Lots more efficient than what I duct tapped together. thank you!

I used this approach to download the newest sdat file, but McAfee has removed the update.ini file from the site, so now my script fails to download.

Any ideas on how to get the most current sdat<####>.exe?

Link to comment
Share on other sites

  • 4 months later...

I used this approach to download the newest sdat file, but McAfee has removed the update.ini file from the site, so now my script fails to download.

Any ideas on how to get the most current sdat<####>.exe?

Yup - this code works below - its a modified version from my original script which checks for the eula if the site hasn't been visited before/in a while.

#include <IE.au3>
dim $sLinkText
dim $sMyString = "sdat"
dim $oSubmit

$oIE = _IECreate ("http://www.mcafee.com/apps/downloads/security_updates/superdat.asp?region=us&segment=enterprise",0,0)

;This checks for the eula agree button and clicks it if present
$oSubmit = _IEGetObjByName ($oIE, "agree")
    _IEAction ($oSubmit, "click")
    _IELoadWait ($oIE)

;*************************************************

$oLinks = _IELinkGetCollection ($oIE)
For $oLink In $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    if StringInStr($sLinkText, $sMyString) then
    inetget ("http://download.nai.com/products/licensed/superdat/english/intel/" & $sLinkText, "C:\users\adam\Desktop\sdat.exe")
    ExitLoop
    EndIf
Next
_IEQuit($oIE)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...