I can't download pictures

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
seb202
Posts: 3
Joined: Mon Dec 06, 2021 10:59 am

I can't download pictures

Post by seb202 » Mon Dec 06, 2021 11:09 am

Hi everyone.
I'm using the free version of iMacros but I will purchase the full version if I can download pictures thanks to it.

The code is really simple, but it keeps says "Error: only one ONDOWNLOAD command should be used for each download"

VERSION BUILD=1011 RECORDER=CR
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
URL GOTO=https://mtgaddict.net/oracle/en/cs-core ... rit-dragon
BACK
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES

I need to download the picture, rename it as 1 then 2 then 3 etc.

Any help will be much appreciated.

Kind regards,
Seb
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I can't download pictures

Post by chivracq » Mon Dec 06, 2021 2:51 pm

seb202 wrote:
Mon Dec 06, 2021 11:09 am
Hi everyone.
I'm using the free version of iMacros but I will purchase the full version if I can download pictures thanks to it.

The code is really simple, but it keeps says "Error: only one ONDOWNLOAD command should be used for each download"

Code: Select all

VERSION BUILD=1011 RECORDER=CR
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
URL GOTO=https://mtgaddict.net/oracle/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon
BACK
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
I need to download the picture, rename it as 1 then 2 then 3 etc.

Any help will be much appreciated.

Kind regards,
Seb

(F)CIM...! :mrgreen: (Read my Sig...)
=> iMacros for CR v10.1.1(...?), 'Free', CR96...?, OS...?

And hum, try to select the "correct" Sub-Forum when you open a Thread, this one has nothing specific to the 'iMacros for CR' Sub-Forum... (especially if you don't even mention your FCI...)
=> I'll move your Thread to the 'Data Extraction & Web-Scraping' Sub-Forum...
EDIT: Done...! (Thread moved.) :P

>>>

Then alright, even without your FCI, well..., the Error you are getting is "normal", you have 2x `ONDOWNLOAD` Commands in your Script, and no Command that triggers a Download...
The `ONDOWNLOAD` Command is "only" meant to specify the `FOLDER` + `FILE` Parameters, but you also need a `SAVEITEM` Command on the Image you want to download, => for example, on the URL you've provided, if I record "tagging" the "Ugin" Image:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
URL GOTO=https://mtgaddict.net/oracle/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon
TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon.jpg
=> + Adding the `SATEITEM` + `ONDOWNLOAD` Commands, and making the URL of the Image a bit more "generic" for the Script to (probably) work on different Pages on the same Site, that will give for example...:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
'URL GOTO=https://mtgaddict.net/oracle/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon
'Download Image:
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
'Recorded:
'TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon.jpg
TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*core-set*/*.jpg CONTENT=EVENT:SAVEITEM
(Tested in iMacros for FF v8.9.7, FF v55.0.3, Win10_x64.)

... And you already have some "1-1-ugin--...etc" in the Filename of the Image being saved (to your Default iMacros 'Downloads' Folder), you probably don't "really need" the "_{{!NOW:...}}" Part indeed in the Name...

>>>
I'm using the free version of iMacros but I will purchase the full version if I can download pictures thanks to it.

Hum..., OK, but you don't "really need" the 'PE' Version for the Functionality that you want, it would also work with the 'Free' Version..., unless you need/want to use the `FOLDER` Param to download the Image(s) to a different Folder than the Default one, and/or if you want to loop your Script >100 Times...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
seb202
Posts: 3
Joined: Mon Dec 06, 2021 10:59 am

Re: I can't download pictures

Post by seb202 » Mon Dec 06, 2021 4:06 pm

Thanks for your prompt reply.
However, do I need the name of the picture on my macro for it to work?

Or can I download a picture that is always at the same position in each page ?

Kind regards,
Sebastien
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I can't download pictures

Post by chivracq » Mon Dec 06, 2021 5:16 pm

seb202 wrote:
Mon Dec 06, 2021 4:06 pm
Thanks for your prompt reply.
However, do I need the name of the picture on my macro for it to work?

Or can I download a picture that is always at the same position in each page ?

Kind regards,
Sebastien

Beh..., no, like I explained, I didn't use the full URL/Name of the Image in the Example I gave in:

Code: Select all

TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*core-set*/*.jpg CONTENT=EVENT:SAVEITEM
=> Like I explained, I tried to make the 'SRC' Attribute a bit more "generic" than keeping the whole URL, for the same Statement to "probably" also work on other Pages with a similar HTML/CSS Structure like that Page, => by only keeping the beginning of the URL ("https://mtgaddict.net/", + ".jpg" for the Extension of the File, and some "core-set" String in the middle that I "guess" will also be present for other Images, and I replaced large parts of the URL with Wildcards (*).

Then you can test yourself if "indeed" the same Statement keeps working on "other" Pages, for other Images, like I reckon it will... (But I didn't try...)

Then OK, I just tried myself, using the exact Script I posted, on the 4 Links just below the "Toutes les impressions" Text Field, as I had commented out the `URL GOTO` Line, then you can test the Script by navigating "manually" to different Pages...
... And..., yep indeed, it works also on the first 3 Links, but it doesn't work on the 4th one (the "Fate Reforged" one), and if I tag/record the Image on that Page, the recorded `TAG` gives:

Code: Select all

'URL GOTO=https://mtgaddict.net/oracle/en/ex-expansions/ktk-khans-of-tarkir-block/frf--fate-reforged/1--ugin--the-spirit-dragon
TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/ex-expansions/ktk-khans-of-tarkir-block/frf--fate-reforged/1--ugin--the-spirit-dragon.jpg
And then..., OK, normal that the Image "doesn't get found", the URL of that Image doesn't contain indeed the "core-set" String I thought would be present for all Images... :oops:

Then, OK, fair enough..., we can adapt the Statement and the 'SRC' Attribute to be "even more generic", with for example:

Code: Select all

TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*/*.jpg CONTENT=EVENT:SAVEITEM
=> And this one works indeed on all 4 Links...! :D
(Tested in iMacros for FF v8.9.7, FF55, Win10_x64.)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
seb202
Posts: 3
Joined: Mon Dec 06, 2021 10:59 am

Re: I can't download pictures

Post by seb202 » Mon Dec 06, 2021 6:18 pm

Thanks a lot !!

I managed to do it, but it saves the files as a 'white paper icon' (so not pictures) :'(

NEVER MIND i got it :) instead of writing "file=1" I wrote file=1.png"
Thanks


Seb
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I can't download pictures

Post by chivracq » Mon Dec 06, 2021 6:56 pm

seb202 wrote:
Mon Dec 06, 2021 6:18 pm
Thanks a lot !!

I managed to do it, but it saves the files as a 'white paper icon' (so not pictures) :'(

NEVER MIND i got it :) instead of writing "file=1" I wrote file=1.png"
Thanks


Seb

Hum..., "strange", because "it" works for me, => I mean this Script:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
'Download Image:
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
'Recorded:
'TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon.jpg
'TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*core-set*/*.jpg CONTENT=EVENT:SAVEITEM

TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*/*.jpg CONTENT=EVENT:SAVEITEM
... And I do get the 4 "Card" ('.jpg') Images correctly saved in my Default iMacros 'Downloads' Folder, the first 3 ones being [26-27]Kb and the 4th one ("the "Fate Reforged" one with the "different" URL) being 127Kb.

Possible Explanation:
I have some Ad-Blocker in that Browser (FF55), that might be blocking some (external) Script(s) and/or Images, maybe included in some Ad(s) that don't get displayed in my Browser for me...

And/or, I guess you are probably logged in on this Site, and might get some "extra" Content and Functionality once you are logged in, you then probably get some extra Images and Icons displayed on the/every Page, and one of those Icons then gets found by the "TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/*/*.jpg" `TAG` Statement, before the Card Image that you want to tag, then I guess you need to "re-add" some Info to the URL, to make sure the Image will be found "first", and your Icon will be "excluded" from that 'SRC' ATTR, => maybe stg like, by keeping the "common" Part from both URL's I had recorded:

Code: Select all

'TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/cs-core-sets/ed-core-set-editions/m21--core-set-2021/1-1-ugin--the-spirit-dragon.jpg
'TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/ex-expansions/ktk-khans-of-tarkir-block/frf--fate-reforged/1--ugin--the-spirit-dragon.jpg
TAG POS=1 TYPE=IMG ATTR=SRC:https://mtgaddict.net/ressources/scans/en/*.jpg CONTENT=EVENT:SAVEITEM
And otherwise, record tagging that Icon, to find out its URL, to manage to specify a 'SRC' ATTR for the Image that will exclude the Icon(s)... :idea:

Or you'd need to play with the `POS` Param, and try with "POS=2"/"=3"/etc, until you find the correct POS-Nb... :idea:

Or use 'Relative Positioning', with the "Impressions" or "Toutes les impressions" Text Field as 'Anchor', that would also be a "neat" Solution... :idea:

Another Option, all 4 Images seem to have the same 'CLASS' ATTR (= "scan"), and I guess your Icon(s) will probably have a different Class, => adding the 'CLASS' ATTR to the `TAG` Statement would also exclude this/those Icon(s), I reckon...:

Code: Select all

TAG POS=1 TYPE=IMG ATTR=CLASS:scan&&SRC:https://mtgaddict.net/*/*.jpg CONTENT=EVENT:SAVEITEM
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply