Jump to content
jasperhale

[Help] Save Images To Disk - Firefox UDF

Recommended Posts

jasperhale

Anyone please help me, sorry for bad english.

I need to download some picture from a website, i use firefox udf

But the problem is, they dont include images to html, but they attach it by encode to base64

So the IMG tag look like this

<img alt="images" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAASUkqAAgAAAAEABoBBQABAAAAPgAAAn8xWVa+m4P8A/G/iHDYXiLALLsbkbrVnHCwx86uaOjhcTOjNVMLSpSlHmdKTp3m+aEoz0ufbeFf0Vvps+I+XYfjPhzLeFsZwjXrY6VOjiM8isyxFLA4+vhJYWrh4YWaw1eusPKph1UrNzpSpz05ml/dJrN4trpl3crexaf9ntmvRdzymOK0VFLtc3UjP5LQ.............example images in base64 encoded...................3X/Lyt3X/T3y/q7BcR51df7fU1X/Puh/07/wCnXm7dg/4e6fs3f9CT8b//AAm/Af8A88qiiitFw/k+n+w0+n/Lyt/c/wCnnn/VkR/rJnf/AEH1P/BVD/5V5L7j/9k=">

 

Please anyone tell me how to save images automatic.

I dont know how to do it

Edited by jasperhale

Share this post


Link to post
Share on other sites
jasperhale

This addon save all picture but i want to use AutoIT for automatic download, because my site have only 1 picture in 1 pages, after that i have to go to next pages and save again.

Please help !!!

Share this post


Link to post
Share on other sites
ssamko

and what about this ? 

 

$linkOfPic="http://i.imgur.com/j3sf8cA.png"
$done=InetGet($linkOfPic, "C:\Users\Samuel\Desktop\pic.jpg" ) ; <-- change your location
If @error Then
   MsgBox(0,"Error","Error")
Else
   MsgBox(0,"Success","Success")
EndIf

 

Share this post


Link to post
Share on other sites
jasperhale

and what about this ? 

 

$linkOfPic="http://i.imgur.com/j3sf8cA.png"
$done=InetGet($linkOfPic, "C:\Users\Samuel\Desktop\pic.jpg" ) ; <-- change your location
If @error Then
   MsgBox(0,"Error","Error")
Else
   MsgBox(0,"Success","Success")
EndIf

 

This work when i have a URL of images, but my site dont have images url, only base64 encode.

What have you tried thus far? Show us your code...

I use FF UDF for get the source of images tag, save to txt file, after that, i use a base64 decoder to decode the txt file content, and save to a jpg file.

I think this is a bad solution, because i missed some picture.

Look like this :

Local $cc = _FFCmd(".images[0].src")

Local $arr2=StringSplit($arr[1],"/")

Local $arr3=StringSplit($arr2[2],";")

Dim $BufferSize = 0x80000
Dim $SrcFile = $fileopen
Dim $DestFile = $filesaved
Dim $SrcFileSize = FileGetSize($SrcFile)
Dim $SrcFileHandle = FileOpen($SrcFile)
Dim $DestFileHandle = FileOpen($DestFile, 2 + 16)
Dim $State = _Base64DecodeInit()
    For $i = 1 To Ceiling($SrcFileSize / $BufferSize)
          FileWrite($DestFileHandle, _Base64DecodeData($State, FileRead($SrcFileHandle, $BufferSize)))
    Next

 

I have attach base64.au3 that i'm using here

 

base64.au3

Edited by jasperhale
attach

Share this post


Link to post
Share on other sites
Danp2

I think this is a bad example because your code is incomplete. :'(

Here are my suggestions:

  • Post a snippet of code that we can actually run.
  • Forget about Firefox for the moment. Instead, use something like this:
    Local $cc = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
    AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
        9TXL0Y4OHwAAAABJRU5ErkJggg=="
  • Stop writing the data to disk before you perform the Base64 conversion
  • Drop the For loop

 

Share this post


Link to post
Share on other sites
Jos

@jasperhale,

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link link in my signature) 
Please read them now carefully and stop PMing people for help. 

See you soon with a legitimate question I hope. :)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×