How to extract data-original-title

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
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
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Mon Aug 14, 2017 2:49 am

widilye wrote:I tried the script code

Code: Select all

SET !EXTRACT https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif
SET Rep_Badge EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/'); y=x[6].split('.'); z=y[0]; z;")
PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>Rep_Badge:<SP>_{{Rep_Badge}}_
PAUSE
Appearance at prompt
However the storage results on the csv file
This confuses me because there is a difference in the prompt display with the storage results in the .csv file. Are there any other suggestions of the script code changes that should be used. :?:
Beeeeh, yep, of course...!, that's normal...! :(
'SAVEAS TYPE=EXTRACT' will save the full Content of the '!EXTRACT' Var at that Moment...
Your "diamond-3" Value is contained in the Var that I called 'Rep_Badge'...; when you want to do your 'SAVEAS', you need to populate '!EXTRACT' with the Data that you want to include in the 'SAVEAS', with a "SET/ADD !EXTRACT {{Rep_Badge}}"...

That Step was not needed previously as you were applying 'EVAL()' directly to '!EXTRACT', which is a bad Practice I told you, (or like I kind of called it, a "fake-semi-advanced Technique to impress Beginners and Script Kiddies"), and can be very dangerous if you do several Extracts in your Script, especially if you don't understand the Principle..., but you need to understand at least a little bit how Variables work...
I'm starting to wonder what you meant with "Please help me to complete my case study."... What did you mean with "case study"...?
- (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...
widilye
Posts: 9
Joined: Sat Jul 15, 2017 12:24 am

Re: How to extract data-original-title

Post by widilye » Mon Aug 14, 2017 12:00 pm

Thank you in advance for helping me with my case study.
I've tried your script by using "SET !EXTRACT {{Rep_Badge}}" and it was saved successfully as expected.

Forgive me for my stupidity, because I do not know exactly how the iMacros script works and I've read and searched for information related to iMacros.

Oh yep, regarding the intent of "Please help me to complete my case study." The purpose of the "case study" is the problem I encountered on my iMacros script that was deadlocked and I have been looking for from various sources and on search engines but have not found a solution to solve my problems on Pb'_1, _2, and _3. But you have helped me and taught me to understand the principles of the workings of iMacros, in this forum I learned a lot about iMacros and I followed the problems that generally occur in iMacros scripts.

So, the problem with the iMacros script code I encountered was a case study for me that had to be done. But I can not understand in detail when I put "SET !EXTRACT" on the stored data has problems that there is some data that does not participate stored. If I use "ADD !EXTRACT" on the data stored many repetition occurs, such as:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
'data pertama yang akan diinput adalah yg ke-1
SET !LOOP 1
URL GOTO=https://www.tokopedia.com/importirshop/munafie-korset-slimming-pants-pakaian-dalam
SET !VAR0 EVAL("Math.floor(Math.random()*5 + 1);")
SET EXTRACT NULL
'Reputation Shop | (Case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET Rep_Badge EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/'); y=x[5].split('.'); z=y[0]; y;")
SET !EXTRACT {{Rep_Badge}}
WAIT SECONDS={{!VAR0}}

'Reputation Point | (case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge-*&&SRC:*&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET Rep_Point EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('-title=\"'); y=x[1].split('\"'); z=y[0]; z;")
SET !EXTRACT {{Rep_Point}}
WAIT SECONDS={{!VAR0}}

'Store Status | (Case Pb's_1)
TAG POS=1 TYPE=I ATTR=CLASS:image-*&&TITLE:&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET Org_Title EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
SET !EXTRACT {{Org_Title}}
WAIT SECONDS={{!VAR0}}

'Save Data.'
SAVEAS TYPE=EXTRACT FOLDER=D:\DROPSHIP\ FILE=toped_list-tes.csv
PAUSE
Data stored just "Gold Merchant" nothing else is stored in a .csv file. But if I replace "SET !EXTRACT" to "ADD !EXTRACT" there is repetition of storage in .csv file ie "diamond-3, 177.897, Gold Merchant, diamond-3, 177.897, Gold Merchant, diamond-3, 177.897, Gold Merchant ,.." So on .... huuuuffft this makes me become dizzy and confused in looking for solving this problem. Hopefully you can give the best solution, especially on Pb's_3 which still make me confused. :?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Mon Aug 14, 2017 1:46 pm

widilye wrote:Thank you in advance for helping me with my case study.
I've tried your script by using "SET !EXTRACT {{Rep_Badge}}" and it was saved successfully as expected.

Forgive me for my stupidity, because I do not know exactly how the iMacros script works and I've read and searched for information related to iMacros.

Oh yep, regarding the intent of "Please help me to complete my case study." The purpose of the "case study" is the problem I encountered on my iMacros script that was deadlocked and I have been looking for from various sources and on search engines but have not found a solution to solve my problems on Pb'_1, _2, and _3. But you have helped me and taught me to understand the principles of the workings of iMacros, in this forum I learned a lot about iMacros and I followed the problems that generally occur in iMacros scripts.

So, the problem with the iMacros script code I encountered was a case study for me that had to be done. But I can not understand in detail when I put "SET !EXTRACT" on the stored data has problems that there is some data that does not participate stored. If I use "ADD !EXTRACT" on the data stored many repetition occurs, such as:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
'data pertama yang akan diinput adalah yg ke-1
SET !LOOP 1
URL GOTO=https://www.tokopedia.com/importirshop/munafie-korset-slimming-pants-pakaian-dalam
SET !VAR0 EVAL("Math.floor(Math.random()*5 + 1);")
SET EXTRACT NULL
'Reputation Shop | (Case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET Rep_Badge EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/'); y=x[5].split('.'); z=y[0]; y;")
SET !EXTRACT {{Rep_Badge}}
WAIT SECONDS={{!VAR0}}

'Reputation Point | (case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge-*&&SRC:*&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET Rep_Point EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('-title=\"'); y=x[1].split('\"'); z=y[0]; z;")
SET !EXTRACT {{Rep_Point}}
WAIT SECONDS={{!VAR0}}

'Store Status | (Case Pb's_1)
TAG POS=1 TYPE=I ATTR=CLASS:image-*&&TITLE:&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET Org_Title EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
SET !EXTRACT {{Org_Title}}
WAIT SECONDS={{!VAR0}}

'Save Data.'
SAVEAS TYPE=EXTRACT FOLDER=D:\DROPSHIP\ FILE=toped_list-tes.csv
PAUSE
Data stored just "Gold Merchant" nothing else is stored in a .csv file. But if I replace "SET !EXTRACT" to "ADD !EXTRACT" there is repetition of storage in .csv file ie "diamond-3, 177.897, Gold Merchant, diamond-3, 177.897, Gold Merchant, diamond-3, 177.897, Gold Merchant ,.." So on .... huuuuffft this makes me become dizzy and confused in looking for solving this problem. Hopefully you can give the best solution, especially on Pb's_3 which still make me confused. :?
Yep, normal-normal, from the 'Command Reference' Page in the Wiki, read the Documentation for the 'SET' + 'ADD' + 'TAG' [+ 'EXTRACT'] + '!EXTRACT' Commands, you need to understand the basic Functionality of those Commands with the Difference between 'SET' and 'ADD', and understand how the 'EXTRACT' Mechanism works...
Only then you will understand how to control the Content of the '!EXTRACT' Var to only include (and only once...!) the Content that you want to save in your '.CSV' File.
And each time you use 'SET' on the same Var (and that applies to '!EXTRACT' as well), you obviously reset that Var to the new Value...

"Case Study" sounds to me like you are doing some "Project" for School, but OK, never mind... 8)
But OK, that means you want to learn, then you need to understand by yourself how the 'EXTRACT' Mechanism works and how to use 'SET' and 'ADD', I'm not really helping you if I correct your Script for you... OK, good luck, you are close...! :wink:
- (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