Jump to content

Downloading Image from Website


Recommended Posts

I am trying to create a code which will navigate to a URL containing a gallery of images and download the main image being shown.

The website in question is puush.me and, using Google Search's first hit, an example would be http://puush.me/Branch/Gallery. The main image would be the large checkerboard picture.

I'm unfamiliar with object operations, and have been unable to make any progress with the ImgGetCollection, BodyReadHTML, and BodyReadText functions. Any guidance would be greatly appreciated.

Link to comment
Share on other sites

I am trying to create a code which will navigate to a URL containing a gallery of images and download the main image being shown.

The website in question is puush.me and, using Google Search's first hit, an example would be http://puush.me/Branch/Gallery. The main image would be the large checkerboard picture.

I'm unfamiliar with object operations, and have been unable to make any progress with the ImgGetCollection, BodyReadHTML, and BodyReadText functions. Any guidance would be greatly appreciated.

http://puush.me use javascript for calculate pic url based on index of clicked pic.

Take a look to their JScripts : pi.imgloaded.js and gallery.js

Pics are stored on http://puu.sh/ ( ex : http://puu.sh/doB9 )

:oops:

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

On a classic Website it can be done like that :

#include <IE.au3>

$f_tryAttach=0
$f_visible=1
$f_wait=1
$oIE = _IECreate ( "http://www.autoitscript.com/", $f_tryAttach, $f_visible, $f_wait )
$oImgs = _IEImgGetCollection ( $oIE )
ConsoleWrite ( "+ There are " & @extended & " images on the page : " & @Crlf )

For $oImg In $oImgs
    $_Url = $oImg.src
    ConsoleWrite ( "- Img Info src= " & $oImg.src & @Crlf )
    InetGet ( $_URL, @DesktopDir & '' & _GetFullNameByUrl ( $_URL ), 1, 0 )
Next
_IEQuit ( $oIE )
Exit

Func _GetFullNameByUrl ( $_FileUrl )
    $_FileName = StringSplit ( $_FileUrl, '/' )
    If Not @error Then Return $_FileName[$_FileName[0]]
EndFunc ;==> _GetFullNameByUrl ( )

but the use of javascript on http://puush.me prevents proper operation...

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

After a bit of messing around, I was able to find the main image URL with _IEBodyReadHTML.

The script continued executing before the image data was loaded onto the webpage (even with proper settings), so a simple sleep command remedied it.

Thanks for the responses.

Link to comment
Share on other sites

After a bit of messing around, I was able to find the main image URL with _IEBodyReadHTML.

The script continued executing before the image data was loaded onto the webpage (even with proper settings), so a simple sleep command remedied it.

Thanks for the responses.

i have tried on ie7 with _IEBodyReadHTML and a big sleep but it return no pic url...

Can you show your code ?

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

$puush = _IECreate("http://puush.me/branch/gallery",0,0,1,0)
sleep(2000)
$HTMLGrab = _IEBodyReadHTML($puush)
_IEQuit($puush)
$URLStart = StringInStr($HTMLGrab,"http://puu.sh")
If ($URLStart=0) Then
Exit 1
Else
$HTMLGrab = StringTrimLeft($HTMLGrab, $URLStart-1)
$ImageURL = StringTrimRight($HTMLGrab, (StringLen($HTMLGrab)-18))
EndIf

The main image is the only one with puu.sh, while everything else still uses puush.me

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...