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
widilye
Posts: 9
Joined: Sat Jul 15, 2017 12:24 am

How to extract data-original-title

Post by widilye » Sat Aug 05, 2017 1:35 pm

Hello, please help. I am new to iMacros and do not understand programming. How to extract Gold Merchant from data-original-title = "Gold Merchant" so it can be stored in the .csv file contained in the following code:

Code: Select all

<i style="outline: 1px solid blue;" data-original-title="Gold Merchant" title="" class="image-gold-merchant cursor-default va-middle"></i>
and how to just extract diamond-3 from src = "https://imagerouter.tokopedia.com/img/n ... mond-3.gif" from the code below:

Code: Select all

<img style="outline: 1px solid blue;" id="shop-reputation-badge-121948" src="https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif" class="w-auto" data-original-title="176.786 points" data-toggle="tooltip" data-placement="top" title="">
Can iMacros make a calculation of the price change of 10% increase from the price of 14.500 so the price becomes 15.950 from the code below, and the final result of the price is extracted and stored in the .csv file

Code: Select all

<span style="outline: 1px solid blue;" class="bold" itemprop="price">14.500</span>
Please help from my 3 problems above, thanks in advance. I use iMacros version buid = 8970419, Mozilla Firfox version 42.0, Windows 7
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Sat Aug 05, 2017 1:58 pm

widilye wrote:

Code: Select all

iMacros version buid = 8970419, Mozilla Firfox version 42.0, Windows 7
Hello, please help. I am new to iMacros and do not understand programming. How to extract Gold Merchant from data-original-title = "Gold Merchant" so it can be stored in the .csv file contained in the following code:

Code: Select all

<i style="outline: 1px solid blue;" data-original-title="Gold Merchant" title="" class="image-gold-merchant cursor-default va-middle"></i>
and how to just extract diamond-3 from src = "https://imagerouter.tokopedia.com/img/n ... mond-3.gif" from the code below:

Code: Select all

<img style="outline: 1px solid blue;" id="shop-reputation-badge-121948" src="https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif" class="w-auto" data-original-title="176.786 points" data-toggle="tooltip" data-placement="top" title="">
Can iMacros make a calculation of the price change of 10% increase from the price of 14.500 so the price becomes 15.950 from the code below, and the final result of the price is extracted and stored in the .csv file

Code: Select all

<span style="outline: 1px solid blue;" class="bold" itemprop="price">14.500</span>
Please help from my 3 problems above, thanks in advance. I use

Code: Select all

iMacros version buid = 8970419, Mozilla Firfox version 42.0, Windows 7
No need to open Duplicates when you want to post on the Forum, and both in the wrong Sub-Forum, grrr...!, your Thread has nothing to do with the Scripting Interface... Correct Sub-Forum was the 'General' one... (But no need to duplicate now...)
Hum, and you could add a Question Mark to your Thread Title, you are not sharing a HowTo...

>>>

1- 'EXTRACT=HTM' + 'EVAL()' with 'split()' or 'match()'.
(I prefer 'split()' myself which doesn't require any 'REGEXP'..., but you'll find Examples for both on the Forum...)

2- 'EXTRACT=HREF' (or '=HTM') + 'EVAL()' with 'split()'.

3- 'EXTRACT=TXT' + 'EVAL()'.

>>>

FYI, v8.9.7 for FF still works fine on FF54, in case you were "afraid" of updating FF... :|
- (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 » Sat Aug 05, 2017 4:05 pm

Forgive me because this is the first time I entered the forum. Thanks for the help but I do not know exactly how to create an iMacros script, can you give me a complete example here so I can understand it because I am new in learning iMacros :|
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Sun Aug 06, 2017 3:17 am

widilye wrote:Forgive me because this is the first time I entered the forum. Thanks for the help but I do not know exactly how to create an iMacros script, can you give me a complete example here so I can understand it because I am new in learning iMacros :|
I asked you to put a Qt Mark to your Thread Title like, but OK never mind...

I said for all "Solutions" I mentioned, you'll find many Examples on the Forum (and many from me btw, ah-ah...! (except with 'match()', I don't like 'REGEXP'...), I always manage to achieve the same Result with 'split()' that I find much easier to use...)... And the Wiki contains Examples as well for all Commands I've mentioned...

I won't be writing your Script, ah-ah...! (and each time I succumb, I regret it later...), to manage your "Expectations", ah-ah...! :twisted: , I already gave you the complete Solution to your 3 Qt's, now you need to "sweat" a little bit, and read a little bit of Documentation..., ah-ah...!
Sorry, I only help Users who try their best and really get stuck... (And I have the "Feeling" you Script is for a Game, I normally don't help Users for Games or Votes...)
- (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 07, 2017 6:30 am

Hi chivracq, i have searched for recommendations you provided through search engines and I tried using EVAL + math () but no results "_undifined_"

Code: Select all

TAG POS=1 TYPE=I ATTR=DATA-ORIGINAL-TITLE:Gold<SP>Merchant EXTRACT=HTM
Set !Var2 Eval("var a = '{{!extract}}'.match(/id=.(.+).\data-original-title=/); a[1];")
Set !Extract Null
Then i tried with EVAL + split ()

Code: Select all

TAG POS=1 TYPE=I ATTR=DATA-ORIGINAL-TITLE:Gold<SP>Merchant EXTRACT=HTM
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('DATA-ORIGINAL-TITLE'); z=y[1].split('title'); z[0].trim();")
Results shown in a .csv file

Code: Select all

<i style="outline: 1px solid blue;" data-original-title="Gold Merchant" title="" class="image-gold-merchant cursor-default va-middle"></i>
Does the code have an error? Please provide appropriate recommendations for the solution. :roll:
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 07, 2017 11:32 am

widilye wrote:Hi chivracq, i have searched for recommendations you provided through search engines and I tried using EVAL + math () but no results "_undifined_"

Code: Select all

TAG POS=1 TYPE=I ATTR=DATA-ORIGINAL-TITLE:Gold<SP>Merchant EXTRACT=HTM
Set !Var2 Eval("var a = '{{!extract}}'.match(/id=.(.+).\data-original-title=/); a[1];")
Set !Extract Null
Then i tried with EVAL + split ()

Code: Select all

TAG POS=1 TYPE=I ATTR=DATA-ORIGINAL-TITLE:Gold<SP>Merchant EXTRACT=HTM
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('DATA-ORIGINAL-TITLE'); z=y[1].split('title'); z[0].trim();")
Results shown in a .csv file

Code: Select all

<i style="outline: 1px solid blue;" data-original-title="Gold Merchant" title="" class="image-gold-merchant cursor-default va-middle"></i>
Does the code have an error? Please provide appropriate recommendations for the solution. :roll:
Yeah, I don't do 'match()', I mentioned, but the 'split()' comes from me, I would think...
Well, 'split()' is possibly/probably Case Sensitive, you need to reuse the exact same String like in the Extract which is without Capitals...
OK, I would expect this one to work:

Code: Select all

SET !EXTRACT NULL
TAG POS=1 TYPE=I ATTR=DATA-ORIGINAL-TITLE:Gold<SP>Merchant EXTRACT=HTM
SET Org_Title EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>Org_Title:<SP>_{{Org_Title}}_
But I don't see the Use to want to isolate "Gold Merchant" from the Extract if you already know this "Gold Merchant" Value as you use it as Attribute in your 'TAG'... :?
- (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 » Tue Aug 08, 2017 4:38 am

I tried the suggestions you gave, the prompt display:

Code: Select all

EXTRACT:
Gold Merchant
Org_Title: __ Gold Merchant__
But the results stored in the .csv file cause the other code to be missing or not saved. I throw in the following code

Code: Select all

SET! EXTRACT NULL
Results in a normal .csv file. Thank you for your help. 1 my problem has been completed.

On the 2nd issue:

Code: Select all

<img style="outline: 1px solid blue;" id="shop-reputation-badge-121948" src="https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif" class="w-auto" data-original-title="176.786 points" data-toggle="tooltip" data-placement="top" title="">
I use the following code 'EXTRACT=HREF' + 'EVAL()' with 'split()' :

Code: Select all

TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/'); z=y[1].split('.gif'); z[0].trim();")
When stored in the .csv file all the extracts in the code script is not stored or appear only on the diamond-3 code only that appears. Is there something wrong with my code so that it can not all be saved in .csv file, please help me for my problem on this iMacros script. :oops:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Tue Aug 08, 2017 4:55 am

widilye wrote:I tried the suggestions you gave, the prompt display:

Code: Select all

EXTRACT:
Gold Merchant
Org_Title: __ Gold Merchant__
But the results stored in the .csv file cause the other code to be missing or not saved. I throw in the following code

Code: Select all

SET! EXTRACT NULL
Results in a normal .csv file. Thank you for your help. 1 my problem has been completed.

On the 2nd issue:

Code: Select all

<img style="outline: 1px solid blue;" id="shop-reputation-badge-121948" src="https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif" class="w-auto" data-original-title="176.786 points" data-toggle="tooltip" data-placement="top" title="">
I use the following code 'EXTRACT=HREF' + 'EVAL()' with 'split()' :

Code: Select all

TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/'); z=y[1].split('.gif'); z[0].trim();")
When stored in the .csv file all the extracts in the code script is not stored or appear only on the diamond-3 code only that appears. Is there something wrong with my code so that it can not all be saved in .csv file, please help me for my problem on this iMacros script. :oops:
OK, Pb_1 solved, good, now you have your "good" Example... Pb's _2 and _3 are even easier, shouldn't be difficult... 8)

"Is there something wrong with my code... [+ Qt Mark maybe if asking a Qt...]" sounds each time quite cute, if you don't get the Result you expect, then I would think, "Yep, there is stg wrong with your Code...!"... :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...
widilye
Posts: 9
Joined: Sat Jul 15, 2017 12:24 am

Re: How to extract data-original-title

Post by widilye » Fri Aug 11, 2017 12:03 am

Hi chivracq can you help me compile the code script from problem Pb's_3 by using 'EXTRACT = TXT' + 'EVAL ()'. I have been through a deadlock and I have searched through the search engine but did not find any examples of such code scripts :oops:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Fri Aug 11, 2017 1:16 am

widilye wrote:Hi chivracq can you help me compile the code script from problem Pb's_3 by using 'EXTRACT = TXT' + 'EVAL ()'. I have been through a deadlock and I have searched through the search engine but did not find any examples of such code scripts :oops:
Yeah but did you find a Solution for Pb_2...?, and if yes, post it...!

Pb_3 looks very simple to me, it's just a simple Multiplication, you don't need to search anything, you need to understand a bit how 'EVAL()' works, you have Examples in the Wiki for 'EVAL()' already... And everything you use inside 'EVAL()' is just "Standard" JavaScript, I use this Site for example for Ref and Documentation... And I'm no JavaScript Guru at all, but doing an Addition or a Multiplication doesn't sound very complicated to me, I would think...

One mini-Tip for searching the Forum and especially inside Scripts that have been posted on the Forum, the Forum Search Engine strangely enough doesn't search inside Scripts formatted with the ]CODE[ Meta-Tags, unless they've been quoted in some later Post... You can then better use Google (+ "iMacros") to locate such Threads/Scripts...
- (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 » Fri Aug 11, 2017 5:18 am

Pb's_1 case problem I am using script:

Code: Select all

TAG POS=1 TYPE=I ATTR=CLASS:image-*&&TITLE:&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
And successfully displayed at prompt:

Code: Select all

Gold Merchant
For Pb's_2 case problem I am using script:

Code: Select all

TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'; var s = s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/')[1]; s = s.split('.gif')[0]; s;")
And successfully displayed at prompt:

Code: Select all

diamond-3
But some results from other missing code scripts are not displayed. If I do not use 'split ()'. Some of the missing code's results can be displayed again.

In case study Pb's_3 I can not solve the problem

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL( )
Okay here's the whole script code and in case Pb's_3 is not in the script code below because I can not solve it yet.

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
'The first data to be inputted is the 1st
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);")

'Reputation Shop | 2- 'EXTRACT = HREF' (or '= HTM') + 'EVAL ()' with 'split ()'. (Case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'; var s = s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/')[1]; s = s.split('.gif')[0]; s;")
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 !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
WAIT SECONDS={{!VAR0}}

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

'Selling Price 10% increase of purchase price | 3- 'EXTRACT = TXT' + 'EVAL ()'. (Case Pb's_3) <--- I can not solve it yet
TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL( )
WAIT SECONDS={{!VAR0}}

'Seller
TAG POS=1 TYPE=A ATTR=ID:shop-name-info&&HREF:*&&CLASS:*&&DATA-TOGGLE:*&&ITEMPROP:*&&DATA-ORIGINAL-TITLE:* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Store Locations
TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:addressLocality EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Name of goods
TAG POS=1 TYPE=H1 ATTR=CLASS:product-title<SP>green* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Address Buy
ATTR=HREF:https://www.tokopedia.com/*/*&&ITEMPROP:name&&CONTENT:* EXTRACT=HREF
WAIT SECONDS={{!VAR0}}
'Pre order
TAG POS=1 TYPE=DIV ATTR=CLASS:po_info_pict*  EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Purchase price
TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/\\./g, ',');")
WAIT SECONDS={{!VAR0}}
'Quality Value
TAG POS=1 TYPE=DIV ATTR=CLASS:clear-b<SP>rate-accuracy<SP>reviewsummary-loop* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Value Accuracy
TAG POS=2 TYPE=DIV ATTR=CLASS:clear-b<SP>rate-accuracy<SP>reviewsummary-loop* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}

'Replace' # EANF # 'Values ​​with' EANF_String 'defined at beginning of Script
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var eanf='{{EANF_String}}'; var z; z=s.split('#EANF#').join(eanf); z;")
WAIT SECONDS={{!VAR0}}
'Save Data.'
SAVEAS TYPE=EXTRACT FOLDER=D:\DROPSHIP\ FILE=toped_list-tes.csv
PAUSE
I am still dodging the script code issues of Pb's_1, Pb's_2 and Pb's_3 and still looking for the best solution for my script problem in learning iMacros, and I'm totally ignorant of javascript, vb, and other coding. Please help me to complete my case study. :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Fri Aug 11, 2017 6:32 pm

OK, let's have a look again, Pb's 2 and 3 should be pretty easy, I thought, compared to 1...
widilye wrote:Pb's_1 case problem I am using script:

Code: Select all

TAG POS=1 TYPE=I ATTR=CLASS:image-*&&TITLE:&&DATA-ORIGINAL-TITLE:* EXTRACT=HTM
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
And successfully displayed at prompt:

Code: Select all

Gold Merchant
OK, this one is settled...
widilye wrote:For Pb's_2 case problem I am using script:

Code: Select all

TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'; var s = s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/')[1]; s = s.split('.gif')[0]; s;")
And successfully displayed at prompt:

Code: Select all

diamond-3
But some results from other missing code scripts are not displayed. If I do not use 'split ()'. Some of the missing code's results can be displayed again.
Yep, this one works "partially" I understand...

OK..., a few Remarks...:
I guess you started from an Example which wasn't from me (I never apply my 'EVAL()' Statements directly to '!EXTRACT' itself, I consider it "Bad Practice" if you need to debug/modify your Script or (later) want to include some (Debug) Logging or Reliability Checks, and makes your own Code more difficult to follow/understand for other Users and is usually used by "semi" Advanced Users to impress a bit other Users...!), notice that in "my" 'EVAL()' for Pb_1, I use "x,y,z" Temp Vars for Temp Calculations or String Manipulations and finish on "z" for the final Result, while you reuse the same "s" Var for all your Temp Statements..., which works indeed, but it's easier to use Temp Vars with different Names like I do to be able to debug each part separately...
Hum, and same Remark about applying your 'EVAL()' directly to '!EXTRACT', you can do it once you are a bit Advanced and know exactly what you are doing, or after you know your Code is working if you want to optimize and shorten it, but that's not a "best Practice" if you are a Beginner and don't sound like you are even able to debug your Script by yourself...

Second Remark is that your first 'split()' (on "https://imagerouter.tokopedia.com/img/nocache/repsys/") is a bit of a "stiff Overkill", ah-ah...! If this part is always present, then you normally would use 'replace()' for that, even if it will indeed work with 'split()' as well, but I would rather use the 'split()' on the "/" in the URL and you are then interested by the Data after the 6th '/', and same thing with the 2nd 'split()', if you do it on the Dot only, your Statement will still work if some Image has a '.png' instead of '.gif' Extension like:

Code: Select all

SET EXTRACT NULL
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
'SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'; var s = s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/')[1]; s = s.split('.gif')[0]; s;")
SET Rep_Badge EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/'); y=x[5].split('.'); z=y[0]; z;")
PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>Rep_Badge:<SP>_{{Rep_Badge}}_
=> I expect it to work directly if I didn't make any Mistake, but in case anything goes "wrong", you can easily debug the 'EVAL()' Statement by changing the last "z" for the Return Value to "y" or "x" to check if those parts work correctly...
widilye wrote:In case study Pb's_3 I can not solve the problem

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL( )
Okay here's the whole script code and in case Pb's_3 is not in the script code below because I can not solve it yet.

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
'The first data to be inputted is the 1st
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);")

'Reputation Shop | 2- 'EXTRACT = HREF' (or '= HTM') + 'EVAL ()' with 'split ()'. (Case Pb's_2)
TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'; var s = s.split('https://imagerouter.tokopedia.com/img/nocache/repsys/')[1]; s = s.split('.gif')[0]; s;")
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 !EXTRACT EVAL("var s='{{!EXTRACT}}'; var y,z; y=s.split('-title=\"'); z=y[1].split('\"'); z[0];")
WAIT SECONDS={{!VAR0}}

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

'Selling Price 10% increase of purchase price | 3- 'EXTRACT = TXT' + 'EVAL ()'. (Case Pb's_3) <--- I can not solve it yet
TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL( )
WAIT SECONDS={{!VAR0}}

'Seller
TAG POS=1 TYPE=A ATTR=ID:shop-name-info&&HREF:*&&CLASS:*&&DATA-TOGGLE:*&&ITEMPROP:*&&DATA-ORIGINAL-TITLE:* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Store Locations
TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:addressLocality EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Name of goods
TAG POS=1 TYPE=H1 ATTR=CLASS:product-title<SP>green* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Address Buy
ATTR=HREF:https://www.tokopedia.com/*/*&&ITEMPROP:name&&CONTENT:* EXTRACT=HREF
WAIT SECONDS={{!VAR0}}
'Pre order
TAG POS=1 TYPE=DIV ATTR=CLASS:po_info_pict*  EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Purchase price
TAG POS=1 TYPE=SPAN ATTR=CLASS:bold&&ITEMPROP:price EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/\\./g, ',');")
WAIT SECONDS={{!VAR0}}
'Quality Value
TAG POS=1 TYPE=DIV ATTR=CLASS:clear-b<SP>rate-accuracy<SP>reviewsummary-loop* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}
'Value Accuracy
TAG POS=2 TYPE=DIV ATTR=CLASS:clear-b<SP>rate-accuracy<SP>reviewsummary-loop* EXTRACT=TXT
WAIT SECONDS={{!VAR0}}

'Replace' # EANF # 'Values ​​with' EANF_String 'defined at beginning of Script
SET !EXTRACT EVAL("var s='{{!EXTRACT}}'; var eanf='{{EANF_String}}'; var z; z=s.split('#EANF#').join(eanf); z;")
WAIT SECONDS={{!VAR0}}
'Save Data.'
SAVEAS TYPE=EXTRACT FOLDER=D:\DROPSHIP\ FILE=toped_list-tes.csv
PAUSE
I am still dodging the script code issues of Pb's_1, Pb's_2 and Pb's_3 and still looking for the best solution for my script problem in learning iMacros, and I'm totally ignorant of javascript, vb, and other coding. Please help me to complete my case study. :)
OK, I don't have much time now for Pb_3, but see if the "Recommendations" I gave for Pb_2 already help you to find the Solution by yourself or at least progress a bit...
- (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 » Sun Aug 13, 2017 11:15 am

Ok, thanks for the suggestion. I tried the script code

Code: Select all

SET EXTRACT NULL
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]; z;")
PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>Rep_Badge:<SP>_{{Rep_Badge}}_
Prompt results

Code: Select all

https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif
"split()" does not work as expected. I have also replaced on "z" with "y" or "x" and the results remain the same. The expected storage result should only take only diamond-3 overall, is there any other way for the script to run properly. Please help for problems Pb's_2 and _3. Thank you for your help.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to extract data-original-title

Post by chivracq » Sun Aug 13, 2017 6:20 pm

widilye wrote:Ok, thanks for the suggestion. I tried the script code

Code: Select all

SET EXTRACT NULL
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]; z;")
PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>Rep_Badge:<SP>_{{Rep_Badge}}_
Prompt results

Code: Select all

https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif
"split()" does not work as expected. I have also replaced on "z" with "y" or "x" and the results remain the same. The expected storage result should only take only diamond-3 overall, is there any other way for the script to run properly. Please help for problems Pb's_2 and _3. Thank you for your help.
Hum..., works fine for me, well Typo on "SET EXTRACT NULL", I forgot the '!", and it seems to be 'x[6]' instead of 'x[5]', but you should have found the Solution by yourself...:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX

'SET !EXTRACT NULL
'TAG POS=1 TYPE=IMG ATTR=ID:shop-reputation-badge* EXTRACT=HREF
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
Result in the 'PROMPT':
EXTRACT:
https://imagerouter.tokopedia.com/img/nocache/repsys/diamond-3.gif

Rep_Badge: _diamond-3_
(Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), 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...
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 1:52 am

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. :?:
Post Reply