Herunterladen defenierten Dateien aus html

  • Hallo zusammen,

    Wie kann man fest definierten Dateien aud der html auslesen? Wenn ich den Inhalt auslese, bekomme ich links mit drin. Was ich herunterladen möchte ist nun alle .pdf und alle files mit Anfangsstring "News_*.*"
    Hat jmd eine Idee?
    Danke

  • ich habe das gleiches Problem und komme auch nicht weiter

    #include <IE.au3>
    #include <MsgBoxConstants.au3>
    #include <Array.au3>
    #include <String.au3>
    #include <IE.au3>
    #include <Inet.au3>

    Local $oIE = _IECreate("http://www.princexml.com/samples/")
    Local $oLinks = _IELinkGetCollection($oIE)
    Local $iNumLinks = @extended
    Local $sTxt1 = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
    $sTxt1 &= $oLink.href & @CRLF
    Next
    MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt1)

    Local $result0=_StringBetween($oIE,'<a href="', '.pdf')
    _ArrayDisplay($result0, "Result") ; hier kommt nichts

    Local $aResult1=StringRegExp($oIE,'"('&"(?:.*?).pdf"&')"',3)
    _ArrayDisplay($aResult1, "Result") ; hier kommt 1

    Local $result1=StringRegExp($sTxt1,'"('&"(?:.*?).pdf"&')"',3)
    MsgBox($MB_SYSTEMMODAL, "Results PDF","Link SA_:" & $aResult1 & @CRLF) ; hier kommt 1

    ;InetGet() --> ?
    ;--------------------
    _IEQuit($oIE)


    Ich würde gern auch wissen wie es gehen würde
    Danke und Gruß

  • Hi,
    _StringBetween() ist mit dem falschen Parameter aufgerufen, wenn du einen Text bearbeiten willst, dann solltest du diesen auch als Parameter verwenden und nicht ein IE-Objekt ;)

    Ich würde aber auch dafür das Regex nehmen:

    AutoIt
    Local $aResult1=StringRegExp($sTxt1,'(?m)^(.*.pdf)',3)
    _ArrayDisplay($aResult1, "Result")
  • Hallo Zusammen und danke für die Rückmeldung.

    Inzwischen habe ich die Lösung. Allerdings werden Datein nur herutergeladen, wenn ich
    $DownloadName
    durch
    Feste Name, z.B. "1.pdf" ersetze.

    Wo steckt noch Fehler? Danke im Voraus für Alle!


    #include <IE.au3>
    #include <MsgBoxConstants.au3>
    #include <Array.au3>
    #include <String.au3>
    #include <IE.au3>
    #include <Inet.au3>
    #include <StringConstants.au3>
    #include <InetConstants.au3>


    Local $i = 0
    Local $oHTMLLink = "http://www.ids.tu-bs.de/studien--und-diplomarbeiten.html"
    Local $oIE = _IECreate($oHTMLLink)
    ;---------------------
    Local $oLinks = _IELinkGetCollection($oIE)
    Local $iNumLinks = @extended
    Local $sTxt1 = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
    $sTxt1 &= $oLink.href & @CRLF
    Local $sResult = $oLink.href & @CRLF
    Local $iPosition = StringInStr($sResult, "SA_")
    If $iPosition >1 Then
    MsgBox($MB_SYSTEMMODAL, "", "The search string with SA_ @CRLF " & $oLink.href, 1)
    Local $sLinkNameResult = $sResult
    Local $aName = StringSplit($sLinkNameResult, "/")
    ;_ArrayDisplay($aName, "Result Name")
    ;MsgBox($MB_SYSTEMMODAL, "", "The name is: " & _ArrayToString($aName, @TAB, $aName[0], $aName[0]), 1)
    Local $sLinkName = "" & _ArrayToString($aName, @TAB, $aName[0], $aName[0])
    MsgBox($MB_SYSTEMMODAL, "", "The name is: " & @CRLF & $sLinkName, 1)
    Example_Download($oLink.href & @CRLF, $sLinkName & @CRLF)
    ;If ($oLink.href) & @CRLF Then MsgBox($MB_SYSTEMMODAL, "Link Info PDF", $oLink.href & @CRLF)
    EndIf
    Next
    MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt1, 1)


    ;--------------------
    _IEQuit($oIE)


    ;Example_Download()
    Func Example_Download($oDownloadLink, $DownloadName)
    MsgBox($MB_SYSTEMMODAL, "Übernommen ... :", $DownloadName, 1)


    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @TempDir & "\" & $DownloadName
    ;Local $sFilePath = @TempDir & "\update.dat"


    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet($oDownloadLink, @ScriptDir & "\" & $DownloadName, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)


    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
    Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)


    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)


    ; Close the handle returned by InetGet.
    InetClose($hDownload)


    ; Display details about the total number of bytes read and the filesize.
    MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
    "The total filesize: " & $iFileSize, 1)


    ; Delete the file.
    FileDelete($sFilePath)
    EndFunc ;==>Example_Download