Jump to content

Extract the images from a website.


Recommended Posts

Hi! 

I would like to download the images (big jpg) from this website:

http://www.flexmls.com/cgi-bin/mainmenu.cgi?cmd=url+other/run_public_link.html&public_link_tech_id=12kn04479qmh&s=12&id=1&cid=1

 

I tried:

_IEImgGetCollection ( ByRef $oObject [, $iIndex = -1] )

_IETagNameGetCollection($oIE, "img")

Reading the img source from the page source

Can you please point me in the right direction, link me a similar question, or show me an example?

I already search in forum without success.

Kind regards

Link to comment
Share on other sites

$oIE = _IECreate("www.google.com")
$oImgs = _IEImgGetCollection($oIE)

$iCounter = 1
For $oImg In $oImgs
    InetGet($oimg.src,"image" & $iCounter & ".bmp")
    $iCounter+=1
Next

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Finally i got it working.

Seems like the image is in a Frame, so i run all the frames and extract the source code.

This is what i got. maybe there is a cleaner/better way to do it. Maybe without hijanking the keyboard...

; Open frameset example, get collection of frames
; and loop through them displaying their source URL's

#include <IE.au3>
#include <timers.au3>
#include <array.au3>
#include <string.au3>
#include <MsgBoxConstants.au3>
FileDelete("output.txt")
Dim $array[1]
$URL = InputBox("", "Select URL", "http://www.flexmls.com/cgi-bin/mainmenu.cgi?cmd=url+other/run_public_link.html&public_link_tech_id=12kn04479qmh&s=12&id=1&cid=1")
$Folder = InputBox("", "Select Folder", "default")
DirCreate(@ScriptDir & "\" & $Folder )
;$oIE = _IEAttach("flexmls")

$oIE = _IECreate($URL)
_IELoadWait2($oIE, 0, 10000)


$down = False
Do
    $Last = ""
    $link = ""
    Do
        $Last = $link
        $link = Extract()
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $r = ' & $link & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

        $f = False
        For $x = 1 To $array[0]
            If $array[$x] == $link Then
                $f = True
                ConsoleWrite(@CRLF & "-> Found" & @CRLF)
                ExitLoop
            EndIf
        Next

        If $f = False Then
            _ArrayAdd($array, $link)
            $array[0] += 1
            $filename = $link
            While StringInStr($filename, "/") > 0
                $filename = StringTrimLeft($filename, StringInStr($filename, "/"))

            WEnd
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $filename = ' & $filename & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            InetGet($link,@ScriptDir & "\" & $Folder & "\" &  $filename)
            FileWriteLine("output.txt", $link)
            $down = False

            ;_ArrayDisplay($array)
            WinActivate("flexmls - ", "")
            Sleep(500)
            ConsoleWrite(@CRLF & "RIGHT" & @CRLF)
            Send("{RIGHT}")
            Sleep(5000)

        Else
            $Last = $link
        EndIf
    Until $Last == $link
    WinActivate("flexmls - ", "")
    Sleep(500)
    Send("{DOWN}")
    If $down = True Then Exit
    $down = True
    ConsoleWrite(@CRLF & "DOWN" & @CRLF)
    Sleep(3000)
Until 0
_ArrayDisplay($array)

Func Extract()
    Local $oFrames = _IEFrameGetCollection($oIE)
    Local $iNumFrames = @extended
    Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
    Local $oFrame = 0
    For $b = 0 To ($iNumFrames - 1)
        $oFrame = _IEFrameGetCollection($oIE, $b)
        $sTxt = StringReplace(_IEPropertyGet($oFrame, "outerhtml"), '"', "") & @CRLF
        $a = _StringBetween($sTxt, "name=listing-photo src=", "onload")
        If IsArray($a) Then Return $a[0]
    Next
EndFunc   ;==>Extract

Func _IELoadWait2(ByRef $site, $wait = 0, $timeout = 60000)
    Sleep($wait)
    $_timer = _Timer_Init()
    While 1
        If _IEPropertyGet($site, "busy") Then $_timer = _Timer_Init()
        If _Timer_Diff($_timer) > $timeout Then Return
    WEnd
EndFunc   ;==>_IELoadWait2
Link to comment
Share on other sites

Using the frame object, you can do the same loop i've already provided to output the images within that frame...no need for the regexp.

What are the sends for?  No need to focus anything on the visible screen to grab it.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...