Jump to content
Sign in to follow this  
BlueC

Downloading Image from Website

Recommended Posts

BlueC

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.

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
BlueC

I'll have to ask for a bigger hint than that, I still have no idea where to even start once I have the webpage opened.

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
BlueC

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.

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
BlueC

$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

Share this post


Link to post
Share on other sites
wakillon

Thinking to no longer hide IE window, I have tried on 2 PC with IE7 and they can't display website because of errors on page.

So i can't test it.

Anyway glad you find a working solution.

What's your IE version ?


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

Share this post


Link to post
Share on other sites
BlueC

IE9

Share this post


Link to post
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
Sign in to follow this  

×