Jump to content

Recommended Posts

Posted (edited)

Hi everyone, hope you are doing fine :)

Well, I'm currently writing a small script that goes to a certain web page, finds the first link of a specified section and download the file associated to this link.

Depending on the computer that the tool is launched, the script gets the computer model and search in the (provided here) ini file which link to follow.

At first, Dell was kind enough to provide only one link but now, they provide two of them. The first one is now a .txt file ( :( ) whereas my script has been designed to download only the fist and latest link released for the BIOS Update.

image.thumb.png.b0b2db304a35e576187ed37123dc2fcb.png

Here's the current code which is working with only the first and latest link of the BIOS category:

  Reveal hidden contents

So the question is: 

In the case of double links like shown in the picture above, how it is possible to tell the script to download only the link containing an the .exe file?

Of course, I could have changed the array result to [1] instead of [0] [which is working] but it seems that Dell does that randomly and that I deal with a lot of computer models.

Thanks for the help you can provide, 

-31290-

 

SEE_BIOS_LINKS.iniFetching info...

Edited by 31290
removed server names

~~~ Doom Shall Never Die, Only The Players ~~~

Posted

You should be able to do this with the standard IE UDF commands. Here's an example --

#include <ie.au3>

Example()

Func Example()
    Local $oIE = _IECreate("http://downloads.dell.com/published/pages/latitude-12-5280-laptop.html", 1)
    Local $oDiv = _IEGetObjById($oIE, "Drivers-Category.BI")
    Local $oTable = _IETagNameGetCollection($oDiv, "Table", 0)
    Local $oRow = _IETagNameGetCollection($oTable, "TR", 1)
    Local $oCell = _IETagNameGetCollection($oRow, "TD", 5)

    Local $oLinks = _IETagNameGetCollection($oCell, "A")

    ConsoleWrite("Found " & $oLinks.length & " links!" & @CRLF)

    For $oLink In $oLinks
        ConsoleWrite($oLink.href & @CRLF)
    Next
EndFunc   ;==>Example

 

Posted (edited)

Hi all, 

Thanks a lot for your inputs :)

To check whether this is a .exe ending link or not, I've simply added 

 

For $oLink In $oLinks
      If StringInStr($oLink.href, ".exe") Then
         ConsoleWrite("Debug: Match!  " & $oLink.href & @LF)
  ;~    Else
  ;~     Do other stuff
      EndIf
    Next

But, taking my InetGet from what was working in my first post code, this is now not working anymore.

$download = InetGet('$oLink.href', $dir, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ;Downloading the BIOS

Do I have to somehow transform the "$oLink.href" variable to something else (string or so?) to make that work?

Edited by 31290
format

~~~ Doom Shall Never Die, Only The Players ~~~

Posted
  On 4/10/2018 at 3:00 PM, Danp2 said:

@31290 Remove the quotes around '$oLink.href' and your InetGet should work. :)

Expand  

Danp2, 

Yes, this is true, no need to add the quotes, my bad :)
How could I have missed that.

Many thanks for your help, all of you!

-31290-

~~~ Doom Shall Never Die, Only The Players ~~~

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
×
×
  • Create New...