Extract ID from ATTR

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
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
Co0oDe
Posts: 12
Joined: Tue Jul 21, 2015 4:17 pm

Extract ID from ATTR

Post by Co0oDe » Tue Jul 21, 2015 4:41 pm

Hello

i'm trying to extract ID from ATTR

here the the code:

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=050848560&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:ltr&&HREF:https://www.domain.com/username?fref=grp_mmbr_list
i want to extract "050848560" only into csv file

how i can do that?
chivracq
Posts: 8716
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract ID from ATTR

Post by chivracq » Tue Jul 21, 2015 10:45 pm

Co0oDe wrote:Hello

i'm trying to extract ID from ATTR

here the the code:

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=050848560&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:ltr&&HREF:https://www.domain.com/username?fref=grp_mmbr_list
i want to extract "050848560" only into csv file

how i can do that?
CIM...! :mrgreen:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Co0oDe
Posts: 12
Joined: Tue Jul 21, 2015 4:17 pm

Re: Extract ID from ATTR

Post by Co0oDe » Wed Jul 22, 2015 1:53 pm

chivracq wrote: CIM...! :mrgreen:
OS: WINDOWS 8.1
iMacros: VERSION BUILD=8920312
Browser: Firefox 39.0
chivracq
Posts: 8716
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract ID from ATTR

Post by chivracq » Wed Jul 22, 2015 2:16 pm

Co0oDe wrote:
chivracq wrote: CIM...! :mrgreen:
OS: WINDOWS 8.1
iMacros: VERSION BUILD=8920312
Browser: Firefox 39.0
Good...! :D

Commands you have to use:
- 'EXTRACT=HTM' on the Element you want to tag:

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=050848560&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:ltr&&HREF:https://www.domain.com/username?fref=grp_mmbr_list EXTRACT=HTM
- The ID Data you want to retrieve should be in that Extract I reckon and you isolate it using 'EVAL()', there are probably several Solutions, the easiest one looks to me using 'split()' (x2).
- 'SAVEAS' for the Saveas, of course...

You can check all Commands I've mentioned with Single Quotes in the Wiki for Syntax and Examples, except 'split()' which is a JavaScript Function, and you post your Final Script once you've managed to get it working (for other Users coming with a similar Question) and I may improve it a bit if things can be improved..., or if you get stuck and don't come out by yourself..., but mention what you've tried and where you get stuck...
You can use 'PROMPT' to debug your Variables... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Co0oDe
Posts: 12
Joined: Tue Jul 21, 2015 4:17 pm

Re: Extract ID from ATTR

Post by Co0oDe » Wed Jul 22, 2015 5:12 pm

chivracq wrote: - The ID Data you want to retrieve should be in that Extract I reckon and you isolate it using 'EVAL()', there are probably several Solutions, the easiest one looks to me using 'split()' (x2).
- 'SAVEAS' for the Saveas, of course...

You can check all Commands I've mentioned with Single Quotes in the Wiki for Syntax and Examples, except 'split()' which is a JavaScript Function, and you post your Final Script once you've managed to get it working (for other Users coming with a similar Question) and I may improve it a bit if things can be improved..., or if you get stuck and don't come out by yourself..., but mention what you've tried and where you get stuck...
You can use 'PROMPT' to debug your Variables... :idea:
its okey!
but how i can extract all ATTR=DATA-HOVERCARD Code?
then using EVAL to extract only "user.php?id=*" number.
i've tried this but it's not working...

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=*&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:*&&HREF:https://www.domain.com/*?fref=grp_mmbr_list EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=* FILE=ID.csv
chivracq
Posts: 8716
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract ID from ATTR

Post by chivracq » Wed Jul 22, 2015 8:53 pm

Co0oDe wrote:
its okey!
but how i can extract all ATTR=DATA-HOVERCARD Code?
then using EVAL to extract only "user.php?id=*" number.
i've tried this but it's not working...

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=*&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:*&&HREF:https://www.domain.com/*?fref=grp_mmbr_list EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=* FILE=ID.csv
After the 'TAG POS=1 ... EXTRACT=HTM" you can see in the Test Popup what Data gets retrieved by the 'EXTRACT'.

Then you need some 'EVAL()' Statement(s) to keep only the Data that you want. And you then put your Final Data back into '!EXTRACT' before doing the 'SAVEAS':

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=*&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:*&&HREF:https://www.domain.com/*?fref=grp_mmbr_list EXTRACT=HTM
SET Split_1 EVAL("... split()...")
SET Split_2 EVAL("... split()...")
PROMPT Split_1:<BR>_{{Split_1}}_<BR><BR>Split_2:<BR>_{{Split_2}}_
SET !EXTRACT {{Split_2}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=ID.csv
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Co0oDe
Posts: 12
Joined: Tue Jul 21, 2015 4:17 pm

Re: Extract ID from ATTR

Post by Co0oDe » Thu Jul 23, 2015 11:12 pm

chivracq wrote: After the 'TAG POS=1 ... EXTRACT=HTM" you can see in the Test Popup what Data gets retrieved by the 'EXTRACT'.

Then you need some 'EVAL()' Statement(s) to keep only the Data that you want. And you then put your Final Data back into '!EXTRACT' before doing the 'SAVEAS':

Code: Select all

TAG POS=1 TYPE=A ATTR=DATA-HOVERCARD:/ajax/hovercard/user.php?id=*&extragetparams=%7B%22fref%22%3A%22grp_mmbr_list%22%7D&&DIR:*&&HREF:https://www.domain.com/*?fref=grp_mmbr_list EXTRACT=HTM
SET Split_1 EVAL("... split()...")
SET Split_2 EVAL("... split()...")
PROMPT Split_1:<BR>_{{Split_1}}_<BR><BR>Split_2:<BR>_{{Split_2}}_
SET !EXTRACT {{Split_2}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=ID.csv
The problem is i have no idea about EVAL()' Statement(s).
any way thank you very much.
i'm still searching for a solution
chivracq
Posts: 8716
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract ID from ATTR

Post by chivracq » Thu Jul 23, 2015 11:29 pm

Co0oDe wrote:The problem is i have no idea about EVAL()' Statement(s).
any way thank you very much.
i'm still searching for a solution
I'm curious to know how you are "searching for a Solution", but the 'EVAL()' Wiki Page will give you a pretty good "idea about 'EVAL()' Statements" and I've already (and I'm not the only one) produced many-many Scripts in many Threads with 'EVAL()' (and with 'split()'), so if you search the Forum a bit, you should find really a few good Examples..., if not already the exact Solution to your Problem... :idea:

(And I use this Site when I need the Syntax and Examples for JavaScript Functions...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply