Jump to content

[Help] Save Images To Disk - Firefox UDF


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • Developers

@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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...